XMS.NET - Error while sending response back to reply queue/out queue

207 views Asked by At

Regarding: “Sending response back to the out/reply queue.”

There is a requirement to send the response back to a different queue (reply queue). While sending the response, we have to use the correlation and message id from the request message and pass it to the reply queue as header. I suspect the format of correlation/message id is wrong.

While reading the message, the correlation id and message id format are as below:

MessageId = “ID:616365323063633033343361313165646139306638346264” CorrelationId = “ID:36626161303030305f322020202020202020202020202020”

While sending the back to out/reply queue, we are passing these ids as below:

ITextMessage txtReplyMessage = sessionOut.CreateTextMessage();

txtReplyMessage.JMSMessageID = “616365323063633033343361313165646139306638346264”; 
txtReplyMessage.JMSCorrelationID = “36626161303030305f322020202020202020202020202020”; 
txtReplyMessage.Text = sentMessage.Contents;
txtReplyMessage.JMSDeliveryMode = DeliveryMode.NonPersistent;
txtReplyMessage.JMSPriority = sentMessage.Priority;
messagePoducerOut.Send(txtReplyMessage);

Please note:

  1. With the XMS.NET library, we need to pass the correlation and message id in string format as per shown above

  2. With MQ API’s (which we were using earlier) passing the correlation and message ids we use to send in bytes format like below:

    MQMessage queueMessage = new MQMessage();

                string[] parms = document.name.Split('-');
                queueMessage.MessageId = StringToByte(parms[1]);
                queueMessage.CorrelationId = StringToByte(parms[2]);
                queueMessage.CharacterSet = 1208;
                queueMessage.Encoding = MQC.MQENC_NATIVE;
                queueMessage.Persistence = 0;  // Do not persist the replay message.
                queueMessage.Format = "MQSTR   ";
                queueMessage.WriteString(document.contents);
                queueOut.Put(queueMessage);
                queueManagerOut.Commit();
    

Please help to troubleshoot the problem.

2

There are 2 answers

11
Nine Friends On

Troubleshooting is a bit difficult because you haven’t clearly specified the trouble (is there an exception, or is the message just not be correlated successfully?). In your code you have missed to add the “ID:” prefix. However, to address the requirements, you should not need to bother too much about what is in this field, because you simply need to copy one value to the other:

txtReplyMessage.JMSCorrelationID = txtRequestMessage.JMSMessageID
0
kaseidu On

A bit unclear what the issue is. Are you able to run the provided examples in the MQ tools/examples? This approach uses tmp queues(AMQ.*) as JMSReplyTo

Start the "server" application first.

Request/Response Client: "SimpleRequestor" Request/Response Server: "SimpleRequestorServer"

You can find the exmaples at the default install location(win): "C:\Program Files\IBM\MQ\tools\dotnet\samples\cs\xms\simple\wmq"

The "SimpleMessageSelector" will show how to use the selector pattern.

Note the format on the selector: "JMSCorrelationID = '00010203040506070809'"

IBM MQ SELECTOR