Chapter 9. Enabling JBoss Messaging Ordering Group
This section describes how to use the JBoss Messaging ordering group feature to achieve strict message ordering.
Message ordering groups is the JBoss Messaging implementation of strict message ordering. When the ordering group feature is enabled, message priorities no longer have an influence on the order that the messages are delivered. Messages of a particular ordering group are delivered in the exact order that they arrive at the target queue (FIFO).
The next message of an ordering group is delivered only after the delivery of the previous messages has been accomplished. To signalize a successful message delivery, the acknowledge mechanism is used (refer to Section 9.1, “Acknowledge Mechanism”).
Transactional Receipt
In the case of the transactional receipt of messages, the next message is not delivered until the transaction has been committed which includes the acknowledgment of the receipt of the current message. If the transaction is rolled back, the message is canceled, sent back to the JMS server, and made available for the next delivery.
9.1. Acknowledge Mechanism
The messages that form a part of an ordering group are delivered one at a time. The next message is delivered only after the delivery of a previous message was completed. Message delivery completion is signaled by various means, depending on the acknowledge mode settings:
- In the
CLIENT_ACKNOWLEDGE
mode, the completion state is signalized by theMessage.acknowledge()
method. - In the
AUTO_ACKNOWLEDGE
andDUPS_OK_ACKNOWLEDGE
modes, the completion is signalized by either of the following:- a successful return from one of the
MessageConsumer
.receive()
methods, or - a successful return from the
onMessage()
call of theMessageListener()
.
Note
If the message consumer is closed, the message being processed at the time of its closure is deemed as completed and that regardless of whether
*_ACKNOWLEDGE
was called prior to the closure of the consumer.