6.0.1 - WebSphere MQ Adapter - Dyanmically setting MQMD Fiel

We have a situation where a message delivered on one MQ queue contains a GroupID (MQMD Group ID) that is used to correlate messages delivered on another separate queue.

The general flow is… get message off queue A, obtain GroupID from that payload, get messsages off queue B that match the GroupID.

I can find no way to pass a Group ID filter dynamically to a Get/Peek service. It appears that Group ID must be known in advance and configured manually in developer. Any assistance is appreciated.

Isn’t it amazing how you find these answers right after you ask for help.

On the Peek service, on the MQMD tab, you can add a selection criteria without specifying any constant value. This adds a selectionCriteria document to the inputs, where I appear able to set the GroupID at runtime.

Thank you, anyone who was going to respond to this, or who can confirm that I’m now going about this the right way.

Well, it’s been a while and development on my project has been going on. We’ve just started to test the actual use of this field to set the Group ID, and it is failing. The Group ID of messages posted is always a string of 24 null (0x00) bytes, regardless of the setting of …/msgHeader/GroupIdByteArray.

While testing posting a message to the queue outside of WebMethods, I produced the sample code I include below. The end result of this code mimics the current behavior I am seeing in WebMethods, if you omit the MQMF_MSG_IN_GROUP flag before posting the message to the queue. Including the MQMF_MSG_IN_GROUP flag correctly includes the Group ID with the message.

How do you tell WebMethods to use the GroupIdByteArray and/or use the MQMF_MSG_IN_GROUP flag when posting messages to the queue?

– BEGIN C# CODE FRAGMENT –

byte[] aPayload = System.Text.Encoding.ASCII.GetBytes( "Queue Message Payload" );
byte[] aGroupID = System.Text.Encoding.ASCII.GetBytes( "THISISASAMP24BYTEGROUPID" );

IBM.WMQ.MQQueueManager qm = new IBM.WMQ.MQQueueManager(
     "QUEUEMANAGER",  // replace with development queue manager name
     "SERVERCHANNEL", // replace with development channel name
     "SERVER(PORT)"); // replace with development server name and port

IBM.WMQ.MQQueue q = qm.AccessQueue(
     "QUEUE",         // replace with development queue name
     IBM.WMQ.MQC.MQOO_OUTPUT );

IBM.WMQ.MQMessage m = new IBM.WMQ.MQMessage();
m.Write( aPayload, 0, aPayload.Length );
m.GroupId = aGroupID;
m.MessageFlags |= IBM.WMQ.MQC.MQMF_MSG_IN_GROUP;   // MUST SPECIFIFY THIS FLAG

q.Put( m );
q.Close();
qm.Close();

– END C# CODE FRAGMENT –

I’ve determined I’m also unable to set MessageSequenceNumber, and that setting MQMF_MSG_IN_GROUP in my MQ API test application (outside of webMethods) also corrects this situation.

There is a MsgFlags exposed in the header that allows one to get/set ‘Message in Group’ or ‘Last Message in Group’. When set, the GroupID and MessageSequenceNumber are both handled correctly.

This resolves this for me, for now.