Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

One JMS queue and multiple MDB

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

HTH,
Vishwa
 
Bruce Snyder
author
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Bruce
 
Ran Pleasant
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kumar

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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic