Asynchronous Message Pipeline Receiving Messages Asynchronously

Developing a Basic JMS Application 5-23 To receive a message, you must create the receiver object and specify whether you want to receive messages asynchronously or synchronously, as described in the following sections. The order in which messages are received can be controlled by the following: ■ Message delivery attributes delivery mode and sorting criteria defined during configuration or as part of the send method, as described in Section 5.3, Sending Messages. ■ Destination sort order set using destination keys, as described in Configure destination keys in the Oracle WebLogic Server Administration Console Help. Once received, you can modify the header field values; however, the message properties and message body are read-only. You can modify the message body by executing the corresponding message types clearbody method to clear the existing contents and enable write permission. For more information about the JMS classes for receiving messages and the message types, see the javax.jms.Message Javadoc, at http:java.sun.comjavaee5docsapijavaxjmsMessage.html . For information about sending messages, see Section 5.3, Sending Messages.

5.4.1 Receiving Messages Asynchronously

This procedure is described within the context of setting up the application. For more information, see Section 5.2.7, Step 6b: Optionally Register an Asynchronous Message Listener.

5.4.1.1 Asynchronous Message Pipeline

If messages are produced faster than asynchronous message listeners consumers can consume them, a JMS server will push multiple unconsumed messages in a batch to another session with available asynchronous message listeners. These in-flight messages are sometimes referred to as the message pipeline, or in some JMS vendors as the message backlog. The pipeline or backlog size is the number of messages that have accumulated on an asynchronous consumer, but which have not been passed to a message listener.

5.4.1.1.1 Configuring a Message Pipeline You can control a clients maximum pipeline

size by configuring the Messages Maximum per Session attribute on the clients connection factory, which is defined as the maximum number of messages that can exist for an asynchronous consumer and that have not yet been passed to the message listener. The default setting is 10. For more information on configuring a JMS connection factory, see Configure connection factories in the Oracle WebLogic Server Administration Console Help.

5.4.1.1.2 Behavior of Pipelined Messages Once a message pipeline is configured, it will

exhibit the following behavior: ■ Statistics — JMS monitoring statistics reports backlogged messages in a message pipeline as pending for queues and durable subscribers until they are either committed or acknowledged. Note: You can control the maximum number of messages that may exist for an asynchronous consumer and that have not yet been passed to the message listener by setting the Messages Maximum attribute when configuring the connection factory. 5-24 Programming JMS for Oracle WebLogic Server ■ Performance — Increasing the Messages Maximum pipeline size may improve performance for high-throughput applications. Note that a larger pipeline will increase client memory usage, as the pending pipelined messages accumulate on the client JVM before the asynchronous consumers listener is called. ■ Sorting — Messages in an asynchronous consumers pipeline are not sorted according to the consumer destinations configured sort order; instead, they remain in the order in which they are pushed from the JMS server. For example, if a destination is configured to sort by priority, high priority messages will not jump ahead of low priority messages that have already been pushed into an asynchronous consumers pipeline.

5.4.2 Receiving Messages Synchronously