High Quality JMS Messaging.

Message Groups (since 7.4.0)

Introduction

A message producer can mark messages which belong together and thus build message groups. The JMS specification reserves the standard message property "JMSXGroupID" for this purpose. All messages with the same value are considered as the same message group and will be dispatched to the same consumer.

For example, assume a producer sends 7 messages and sets the property JMSXGroupID to the values "A", "B", "A", "C", "B", "A", "C". If there were 3 consumers on the queue, one consumer gets all messages with "A", another consumer gets all with "B" and the 3rd gets all with "C". If there were only 2 consumers on the queue, one would get all "A", the other all "B" and one of them additionally all "C".

Configuration

Message groups are part of the clustered queue configuration since SwiftMQ release 7.4.0:

"Message Group Enabled" enables/disables message groups for this clustered queue. If this property is disabled, round-robin message distribution takes place so you have the same behavior as in previous releases.

"Message Group Expiration" sets a timeout in milliseconds after which a message group expires after this value has been sent the last time. For example, if the value "A" has been sent 30 seconds ago and the expiration is 30000 ms (30 secs), the value (group) "A" has expired and will be removed by the cleanup (see next section). Expiration is useful to save router memory by removing message groups which are not being used anymore.

"Message Group Expiration Cleanup Interval" is the interval in which expired message groups are removed.

"Message Group Property" is the name of the message property used for message grouping. The default is "JMSXGroupID". This can be any property of any type.

Message Group Lifetime

A message group lives as long as its consumer lives or it expired. If a consumer disconnects, the remaining messages in the consumers physical queue are redispatched (if enabled) and a new consumer is selected which will "own" this group.

JMS Usage

A producer marks messages as message groups by setting the message group property configured for the clustered queue:

      Message message = session.createTextMessage("bla");
      message.setStringProperty("JMSXGroupID", "G1");
      ...
      producer.send(message);

Limitations

Message groups works best with Local Clustering (a clustered queue defined and used at a single router only) or in a Federated Router Network if producers on different routers produce different message groups. In case that different producers on different routers produce the same message group (e.g. value "XYZ"), each router will select their own consumer for this group and thus the message group is splitted over multiple consumers. The reason is that message group assignments are not exchanged between the clustered queues on each router.