Chapter 27. Message Grouping

Message groups are sets of messages that has the following characteristics:

27.1. Using Core API

The property name used to identify the message group is "_JBM_GROUP_ID"" (or the constant MessageImpl.HDR_GROUP_ID). Alternatively, you can set autogroup to true on the SessionFactory which will pick a random unique id.

27.2. Using JMS

The property name used to identify the message group is JMSXGroupID.

Within the same group, messages can also set a JMSXGroupSeq int property (starting at 1).

 // send 2 messages in the same group to ensure the same
 // consumer will receive both
 Message message = ...
 message.setStringProperty("JMSXGroupID", "Group-0");
 message.setIntProperty("JMSXGroupSeq", 1);
 producer.send(message);

 message = ...
 message.setStringProperty("JMSXGroupID", "Group-0");
 message.setIntProperty("JMSXGroupSeq", 2);
 producer.send(message);          
       

Alternatively, you can set autogroup to true on the JBossConnectonFactory which will pick a random unique id. This can also be set in the jbm-jms.xml file like this:

<connection-factory name="ConnectionFactory">
      <connector-ref connector-name="netty-connector"/>
      <entries>
         <entry name="ConnectionFactory"/>
      </entries>
      <autogroup>true</autogroup>
</connection-factory>

27.3. Example

See Section 9.1.29, “Message Group” for an example which shows how message groups are configured and used with JMS.