Imagine that we have a JMS queue and tens of thread listening on this queue, each thread has its own connection object and onMessage method.
Now my question is: - How does JMS guarantee that each message just deliver once? - If we use client acknoledge for session then, will queue locks until each message acknoledge or acknoledging message can be Asych ?
Originally posted by Rahul Bhattacharjee: First of all , for queue there should be only one consumer of the message and if there is more then the JMS doesn't guarantee anything,any one of the clients might get the message or none might get.
This is a provider specific stuff. More discussions here What i think, using different consumers with different selectors is a valid scenario isnt it? It comes to the point that whether i would use a different queue for broadly same but slightly different messages or i use a filter on each consumer based on the slight difference. As mentioned in the above link, having multiple consumers also facilitate a better processing power as messages can be consumed and processed concurrently. Ofcourse, such an application will not be portable as the behavior is undefined by the spec. [ May 09, 2007: Message edited by: Nitesh Kant ]
I want the message to be delivered to one and only one of them.
Certainly you can , that is the only purpose of Queue.
Adding to Nitesh.As multiple consumer behaviors is not there in the JMS specification , it would not be wise for having multiple consumer for a single queue.But many vendors might implement this feature for queues also but will hit portability a lot and off course the basic reason of WORA.
You can use topics in that case. [ May 09, 2007: Message edited by: Rahul Bhattacharjee ]
subject: How does JMS queue works correct when it has tens of clients?