Reputation: 31
I'm new to JMS Queue. Please advice me on the following:
Do we need to use the QueueBrowser.getEnumeration() only at the client end, just before consuming the next message? Or can we use it from the sender side to browse the messages in the queue which we can retrieve from the context using the queuename?
Is there any restrictions to be followed to browse messages of a queue? Because I never get elements in QueueBrowser.getEnumeration(); always it was an empty one!
Thanks in advance.
Upvotes: 2
Views: 1405
Reputation: 15283
A QueueBrowser
as the name Browser
suggests,is required if you want to take a look at a message in a queue without removing it from the queue. On the other hand a QueueReceiver
is used to receive message and remove it from the queue.
Unless there is a specific requirement, there is no need to use QueueBrowser to inspect a message and then use QueueReceiver to consume messages. You can consume messages in the order they are produced or use selector to consume messages that match a certain criteria.
There is no restriction on using QueueBrowser anywhere, sender or receiver, based on your application design requirements.
Upvotes: 1