my dog learned polymorphism*
The moose likes EJB and other Java EE Technologies and the fly likes How does JMS queue works correct when it has tens of clients? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "How does JMS queue works correct when it has tens of clients?" Watch "How does JMS queue works correct when it has tens of clients?" New topic
Author

How does JMS queue works correct when it has tens of clients?

raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
Hi
Thank you for reading my post.

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 ?


Thanks
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
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.

You should use Topic's in such case.


Rahul Bhattacharjee
LinkedIn - Blog
raminaa niilian
Ranch Hand

Joined: Jul 14, 2005
Posts: 551
Thank you for reply
I want the message to be delivered to one and only one of them.

is it possible?

Thanks
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

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 ]

apigee, a better way to API!
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Originally posted by raminaa niilian:

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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How does JMS queue works correct when it has tens of clients?
 
Similar Threads
Maximum Connections in Weblogic.. please Help
JMS in Stateless Bean
How to use JMS MESSAHE SELECTOR
Need Open Source email sending application
Using JMS in distributed systems