views:

29

answers:

1

Hi, I'm connecting to an IBM Websphere MQ and currently reading one message at a time using the method receive() from the object:

javax.jms.Message;

Is there a way to retrieve multiple messages from the queue in one go?

Many thanks, G.

+1  A: 

Depends on whether you make a distinction between "read" and "retrieve".

From a JMS perspective, no. The API will return one message per method call.

From the WMQ perspective, yes - provided the client and queue manager are both at v7 and the messages are non-persistent or being browsed. In this case you can enable read-ahead in the managed object definition or dynamically at run time. The queue manager will stream several messages off of the queue and deliver them to the application before the first one is acknowledged. For more information on this, see Using read ahead with WebSphere MQ classes for JMS.

T.Rob
thank you. That was very useful!
javaExpert
I neglected to mention that with a pure v7 setup, message selectors are processed at the QMgr so it is MUCH faster than with v6 and you won't be tossing away otherwise good messages that are pre-fetched on behalf of an app with selectors specified.
T.Rob