Red Hat Training
A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform
Chapter 22. Message Grouping
A message group is a group of messages that share certain characteristics:
- All messages in a message group are grouped under a common group id. This means that they can be identified with a common group property.
- All messages in a message group are serially processed and consumed by the same consumer, irrespective of the number of customers on the queue. This means that a specific message group with a unique group id is always processed by one consumer when the consumer opens it. If the consumer closes the message group, then the entire message group is directed to another consumer in the queue.
Message groups are especially useful when there is a need for messages with a certain value of the property (group id) to be processed serially by a single consumer.
Message grouping will not work as expected if the queue has paging enabled. Be sure to disable paging before configuring a queue for message grouping.
For information about configuring message grouping within a cluster of messaging servers, see Clustered Message Grouping in Part III, Configuring Multiple Messaging Systems.
22.1. Configuring Message Groups Using the Core API
_AMQ_GROUP_ID is used to identify a message group using the Core API on the client side. To pick a random unique message group identifier, you can also set the
auto-group property to
true on the
22.2. Configuring Message Groups Using JMS
JMSXGroupID is used to identify a message group for Java Messaging Service (JMS) clients. If you wish to send a message group with different messages to one consumer, you can set the same
JMSXGroupID for different messages.
Message message = ... message.setStringProperty("JMSXGroupID", "Group-0"); producer.send(message); message = ... message.setStringProperty("JMSXGroupID", "Group-0"); producer.send(message);
An alternative approach is to use the one of the following attributes of the
connection-factory to be used by the client:
auto-group is set to
connection-factory will begin to use a random unique message group identifier for all messages sent through it. You can use the management CLI to set the
group-id attribute will set the property
JMSXGroupID to the specified value for all messages sent through the connection factory. To set a specific
group-id on the connection factory, use the management CLI.