Messages may be delivered out of sequence , EJB specs does not gurantee message delivery order.
See Section 5.4.11 of ejb 3.1 spec.
A container allows many instances of a message-driven bean class to be executing concurrently, thus allowing for the concurrent processing of a stream of messages. No guarantees are made as to the exact order in which messages are delivered to the instances of the message-driven bean class, although the container should attempt to deliver messages in order when it does not impair the concurrency of message processing. Message-driven beans should therefore be prepared to handle messages that are out of sequence: for example, the message to cancel a reservation may be delivered before the message to make the reservation.
However,The example above sends only one message when i issue a request using URL.
My Question is why the order in which beans were created ( i.e. 1,2,3) are not getting the message in the same order ?
The order of message receivable is opposite of Bean creation Each of the three message driven beans receive a copy of the message sent to the topic
Joined: Aug 18, 2008
Order of bean creation is not tied to order in which they recieve the messages
MDB very much works like stateless session beans , where in container creates pool of MDB instances once the bean is deployed.
once we have a pool , Container can pick any instance from the pool and delegate it to process the message. Order is not supposed to be preserved.