tibcoems

Consume multiple messages from a queue in Tibco EMS


Is it possible to consume multiple messages in one call from a Tibco EMS queue. I am using the Receive method of the MessageConsumer class to consume the data currently but this just returns one Message. I'm wondering if there's something that returns an array of Message objects?

Thanks


Solution

  • A queue should not be treated as an inbound array object... mostly because the number of such objects could be massive... and such behaviors would be in direct contradiction with the basic "atomic information piece" notions of messaging. Queues should really be seen as an input "faucet" providing a flux of information.

    That said : You might be looking for the javax.jms.QueueBrowser facility object. It IS in contradiction of typical messaging patterns, but can be useful. (Rules are meant to be broken sometimes, are they not ?) Here is a link to many related examples. EMS is a JMS provider, so these examples can be used with it.

    To retrieve specific messages (to put in an array ?), you could then use a "receive" with message selectors (ex: on the message ID)

    UPDATE : There is also this non-jms response : Use the Native EMS API to purge.