Enterprise JavaBeans

JMS and Message-Driven Bean

How does Message-Driven Bean work?

When a message-driven bean is deployed, it's assigned to handle messages from a specific topic or queue. Any messages sent by a JMS client (Java application, bean, or native client) will be forwarded by the message router to the message bean. 

When a message is delivered to a message bean, one instance of that bean is selected by the EJB container from a pool to handle the message. The bean instance will receive the message when its onMessage() method is invoked and can process the message by calling helper methods, or it may invoke a session or entity bean to process the information in the message.

Once the message is consumed, it won't be delivered to any other instance of that message bean, providing that the transaction is not aborted.