Show Table of Contents
26.2. Using JMS
The property name used to identify the message group is
JMSXGroupID.
// send 2 messages in the same group to ensure the same
// consumer will receive both
Message message = ...
message.setStringProperty("JMSXGroupID", "Group-0");
producer.send(message);
message = ...
message.setStringProperty("JMSXGroupID", "Group-0");
producer.send(message);
Alternatively, you can set
autogroup to true on the HornetQConnectionFactory which will pick a random unique id. This can also be set in the JBOSS_DIST/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-jms.xml file like this:
<connection-factory name="NettyConnectionFactory">
<connectors>
<connector-ref connector-name="netty-connector"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
</entries>
<autogroup>true</autogroup>
</connection-factory>
Alternatively you can set the group id via the connection factory. All messages sent with producers created via this connection factory will set the
JMSXGroupID to the specified value on all messages sent. To configure the group id set it on the connection factory in the hornetq-jms.xml configuration file as follows:
<connection-factory name="NettyConnectionFactory">
<connectors>
<connector-ref connector-name="netty-connector"/>
</connectors>
<entries>
<entry name="/ConnectionFactory"/>
</entries>
<group-id>Group-0</group-id>
</connection-factory>

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.