With a queue, only one bean gets the message. Period.

If you have a queue for messages requesting that a new customer be processed, only one bean from the pool associated with that queue will get the message. That’s it.

Oh, and don’t even think about asking what happens if you have more than one bean type (pool) associated with that queue.

But if you persist, we’ll tell you that JMS doesn’t define what happens when there is more than one consumer for a particular queue. That means there’s no way to know how the messages might be distributed among the different queue consumers. Maybe the messaging service will just pick one at random. But maybe it won’t. Maybe it’ll just pick the first one in a properties file and send everything there. So, just don’t do it.

Note

Only one bean in the pool will get the message. NOT every bean in the pool!

image with no caption

Get Head First EJB now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.