1

I'm currently faced with a use case where I need to process multiple messages in parallel, but related messages should only be processed by one JMS consumer at a time.

As an example, consider the messages ABCDEF and DEFGHI, followed by a sequence number:

  • ABCDEF-1
  • ABCDEF-2
  • ABCDEF-3
  • DEFGHI-1
  • DEFGHI-2
  • DEFGHI-3

If possible, I'd like to have JMS consumers process ABCDEF and DEFGHI messages in parallel, but never two ABCDEF or DEFGHI messages at the same time across two or more consumers. In my use case, the ordering of messages is irrelevant. I cannot use JMS filters because I would not know the group name ahead of time, and having a static list of group names is not feasible.. Messages are sent via a system which is not under my control, and the group name always consists of 6 letters.

ActiveMQ seems to have implemented this via their message groups feature, but I can't find equivalent functionality in IBM MQ. My understanding is that this behaviour is driven by JMSXGroupId and JMSXGroupSeq headers, which are only defined in an optional part of the JMS specification.

As a workaround, I could always have a staging ground (a database perhaps), where all messages are placed and then have a fast poll on this database, but adding an extra piece of infrastructure seems overkill here. Moreover, it would also not allow me to use JMS transactions for reprocessing in case of failures.

To me this seems like a common use case in messaging architecture, but I can't find a simple yes/no answer anywhere online, and the IBM MQ documentation isn't very clear about whether this functionality is supported or not.

Thanks in advance

justin.saliba
  • 724
  • 1
  • 9
  • 17
  • Ibm mq did not support a feature like the ActiveMQ message groups feature you highlighted. You would need to write your own logic using the header fields Morag pointed out. – JoshMc May 12 '21 at 10:11
  • Thanks Josh, do you have a link to IBM MQ's documentation page that specifically says that this isn't supported by any chance? I'm hoping that there are some helpful links that might explain how we would go about implementing this ourselves ... it sounds like a typical use case for a message broker but I may be wrong. – justin.saliba May 12 '21 at 12:36
  • Since it doesn't have a feature like that I wouldn't expect there to be a doc page stating that it doesn't have that feature. – JoshMc May 12 '21 at 18:37

1 Answers1

0

IBM MQ also has the concept of message groups.

The IBM MQ message header, called the Message Descriptor (MQMD) has a couple of fields in it that the JMS Group fields map to:-

  • JMSXGroupID -> MQMD GroupID field
  • JMSXGroupSeq -> MQMD MsgSeqNumber field

Read more here

Morag Hughson
  • 7,255
  • 15
  • 44
  • Thanks Morag. I did look at those documentation pages, and I developed a POC that sets the MQMDGroupID and MQMDMsgSeqNumber headers on the MQ message but they're not respected by the message consumers. Messages that have the same group ID are processed by different consumers (and therefore different threads). The second documentation page looks promising but is somewhat confusing because it bundles message groups (different versions of the same logical object) with message segments (same message segmented into multiple, smaller messages) – justin.saliba May 12 '21 at 10:38
  • I am facing a similar problem. The Message groups behavior is a default feature within IBM MQ queues or it must be configured upon Queue creation ? – mario martinez May 12 '21 at 12:31
  • IBM MQ message grouping is handled at the application level and not at queue creation. A queue can handle messages that are in a group and not in a group at the _**same time**_. – Roger May 12 '21 at 16:29
  • @justin.saliba - sounds like you have a coding question - could you update your question with your code and then we might be able to help you with how you have gone wrong. Sounds like specifically we want to see the code for your consumers. – Morag Hughson May 13 '21 at 07:29