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
To receive messages synchronously, use the following MessageConsumer methods: public Message receive
throws JMSException public Message receive
long timeout throws JMSException
public Message receiveNoWait throws JMSException
In each case, the application receives the next message produced. If you call the receive method with no arguments, the call blocks indefinitely until a message is
produced or the application is closed. Alternatively, you can pass a timeout value to specify how long to wait for a message. If you call the receive method with a
value of 0, the call blocks indefinitely. The receiveNoWait method receives the next message if one is available, or returns null; in this case, the call does not block.
The MessageConsumer class methods are inherited by the QueueReceiver and TopicSubscriber classes. For additional information about the MessageConsumer
class methods, see the javax.jms.MessageConsumer Javadoc, at http:java.sun.comjavaee5docsapijavaxjmsMessageConsumer.
html .
5.4.2.1 Use Prefetch Mode to Create a Synchronous Message Pipeline
In releases prior to WebLogic Server 9.1, synchronous consumers required making a two-way network calls for each message, which was an inefficient model because the
synchronous consumer could not retrieve multiple messages, and could also increase network traffic resources, since synchronous consumers would continually poll the
Notes: The Messages Maximum per Session pipeline size setting on
the connection factory is not related to the Messages Maximum quota settings on JMS servers and destinations.
Pipelined messages are sometimes aggregated into a single message on the network transport. If the messages are sufficiently large, the
aggregate size of the data written may exceed the maximum value for the transport, which may cause undesirable behavior. For example,
the t3 protocol sets a default maximum message size of 10,000,000 bytes, and is configurable on the server with the MaxT3MessageSize
attribute. This means that if ten 2 megabyte messages are pipelined, the t3 limit may be exceeded.
Developing a Basic JMS Application 5-25
server for available messages. In WebLogic 9.1 or later, your synchronous consumers can also use the same efficient behavior as asynchronous consumers by enabling the
Prefetch Mode for Synchronous Consumers option on JMS connection factories, either using the Administration Console or the JMSClientParamsBean MBean.
Similar to the asynchronous message pipeline, when the Prefetch Mode is enabled on a JMS clients connection factory, the connection factorys targeted JMS servers will
proactively push batches of unconsumed messages to synchronous message consumers, using the connection factorys Messages Maximum per Session parameter
to define the maximum number of messages per batch. This may improve performance because messages are ready and waiting for synchronous consumers
when the consumers are ready to process more messages, and it may also reduce network traffic by reducing synchronous calls from consumers that must otherwise
continually poll for messages.
Synchronous message prefetching does not support user XA transactions for synchronous message receives or multiple synchronous consumers per session
regardless of queue or topic. In most such cases, WebLogic JMS will silently and safely ignore the Prefetch Mode for Synchronous Consumer flag; however, otherwise
WebLogic will fail the applications synchronous receive calls.
For more information on the behavior of pipelined messages, see Section 5.4.1.1,
Asynchronous Message Pipeline. For more information on configuring a JMS
connection factory, see Configure connection factories in the Oracle WebLogic Server Administration Console Help.
5.4.2.2 Receiving Messages Synchronously Within a PTP Application