File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes One JMS queue and multiple MDB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of RabbitMQ in Depth this week in the Open Source forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "One JMS queue and multiple MDB " Watch "One JMS queue and multiple MDB " New topic

One JMS queue and multiple MDB

Kumar Gaurav
Ranch Hand

Joined: Apr 08, 2008
Posts: 108
Hi All,

My problem is whether we can have more than one MDB bind to a single queue and if yes how to ensure each MDB consumes its intended message meant for that MDB only.

Please help me out

Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
Hi Kumar,

You can have more than one MDB listening on a queue but only one of those (randomly picked) would receive the message.
So, no, you cannot have "each" MDB to receive that message in the first place. In this case, you can use a topic.


Bruce Snyder

Joined: Nov 03, 2010
Posts: 10
Yes, more than one MDB can listen to the same queue. The only way to target certain messages for certain MDBs is to use JMS selectors. You can find more info about JMS selectors in The JMS API Programming Model.

Ran Pleasant
Ranch Hand

Joined: Jan 16, 2003
Posts: 76

Keep in mind that a single large queue or topic is considered an anti-pattern. It looks good on paper but can be a dog in production and a dog to maintain. Building a number of specific queue or topic will be easier to maintain and give better performance.

I agree. Here's the link:
subject: One JMS queue and multiple MDB