JMS implementers have a message grouping feature that allows messages to be grouped together and process messages in an order in that group. All the messages in a group are received by the same consumer. The messages in a group are ordered using a sequence number. JMS defines JMSXGroupdID
and JMSXGroupSeq
properties for this purpose.
You can use the JMSXGroupID
property to group all the messages read from files and use a unique JMSXGroupSeq
property for each message in the group. Consumers must look for messages with group id and start picking up messages until the JMSXGroupSeq
property value is -1. That signals the end of the group.
Sample and more details are here