|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Issue with JMSmessageID on Reply to Queue |
« View previous topic :: View next topic » |
Author |
Message
|
gops |
Posted: Wed Dec 16, 2009 2:59 am Post subject: Issue with JMSmessageID on Reply to Queue |
|
|
Novice
Joined: 05 Mar 2008 Posts: 10
|
In AppA and AppB integration we have to paths.
1) AppA --> requestQueue(MQ server) --> MDB.
2) MDB --> ResponseQueue(MQ server) --> AppA
In request path AppA creates BytesMessage object which contains JMSMessageID (hexa decimal value which gets generated at the time of creating BytesMessage object) ,sets the request string into BytesMessage object
and sends the BytesMessage to requestQueue. MDB listens to requestQueue and gets the message.
In response path MDB sets the response string into ByteMessage and sending it to ResponseQueue(MQ server).In the MDB ,the value of JMSMessageID is same as AppA generated JMSMessageID. In ResponseQueue(MQ server) ,the JMSMessageID of reply message is getting incremented.
AppA is polling the ResponseQueue(MQ server) with JMSMessageID (which is generated by AppA while sending the message) for the response message. But response message in ResponseQueue(MQ server) is having incremented JMSMessageID.
So AppA is not able get the response back. AppA polling ResponseQueue(MQ server) with JMSMessageID as mentioned below.
private QueueReceiver getQueueReceiver(String pCorrId)
throws JMSException {
Queue q = getQueue( LOCAL_REPLY_QUEUE , true );
String selector = "JMSMessageID = '" +pCorrId+ "'" ;
QueueReceiver receiver = (QueueReceiver)
fSession .createReceiver(q, selector);
return receiver;
}
We changed the selector value to String selector = " JMSCorrelationID = ' "+pCorrId+"'" and in Message Driven Bean of stub application we are copying JMSMessageID to JMSCorrelationID a nd sending message back to ResponseQueue(MQ server).Now AppA is poling the ResponseQueue(MQ server) with JMSCorrelationID . Since JMSCorrelationID is not getting changed or incremented after sending it to ResponseQueue(MQ server) AppA able to get the response back. But we should not change the AppA code, we should be able to get response back with JMSMessageID itself. Please guide me to get the JMSCorrelationID of reply message same as Request message. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Dec 16, 2009 5:24 pm Post subject: Re: Issue with JMSmessageID on Reply to Queue |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
gops wrote: |
In AppA and AppB integration we have to paths.
1) AppA --> requestQueue(MQ server) --> MDB.
2) MDB --> ResponseQueue(MQ server) --> AppA
In request path AppA creates BytesMessage object which contains JMSMessageID (hexa decimal value which gets generated at the time of creating BytesMessage object) ,sets the request string into BytesMessage object and sends the BytesMessage to requestQueue. MDB listens to requestQueue and gets the message. |
I was under the impression that the messageId gets allocated at the time of execution of the send method and is available to the sender after the send completed... So the timing you described above would be wrong...
gops wrote: |
In response path MDB sets the response string into ByteMessage and sending it to ResponseQueue(MQ server).In the MDB ,the value of JMSMessageID is same as AppA generated JMSMessageID. In ResponseQueue(MQ server) ,the JMSMessageID of reply message is getting incremented.
AppA is polling the ResponseQueue(MQ server) with JMSMessageID (which is generated by AppA while sending the message) for the response message. But response message in ResponseQueue(MQ server) is having incremented JMSMessageID.
|
Working as designed. JMS does not allow you to set the messageId. You can however set the JMSCorrelationID...
gops wrote: |
So AppA is not able get the response back. AppA polling ResponseQueue(MQ server) with JMSMessageID as mentioned below.
private QueueReceiver getQueueReceiver(String pCorrId)
throws JMSException {
Queue q = getQueue( LOCAL_REPLY_QUEUE , true );
String selector = "JMSMessageID = '" +pCorrId+ "'" ;
QueueReceiver receiver = (QueueReceiver)
fSession .createReceiver(q, selector);
return receiver;
}
We changed the selector value to String selector = " JMSCorrelationID = ' "+pCorrId+"'" and in Message Driven Bean of stub application we are copying JMSMessageID to JMSCorrelationID a nd sending message back to ResponseQueue(MQ server).Now AppA is poling the ResponseQueue(MQ server) with JMSCorrelationID . Since JMSCorrelationID is not getting changed or incremented after sending it to ResponseQueue(MQ server) AppA able to get the response back. But we should not change the AppA code, we should be able to get response back with JMSMessageID itself. Please guide me to get the JMSCorrelationID of reply message same as Request message. |
Working as designed. You need to follow the industry patterns for request / response in your design. In JMS the Correlation Id will have the value of the request's message ID.
The typical check in the server process is:
Check if message correlation-id is initial. If it is not initial copy the request correlationId to the response correlation-id. If it is initial copy the request message-id to the correlation-id...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
mvic |
Posted: Tue Dec 22, 2009 4:03 pm Post subject: Re: Issue with JMSmessageID on Reply to Queue |
|
|
 Jedi
Joined: 09 Mar 2004 Posts: 2080
|
fjb_saper wrote: |
In JMS the Correlation Id will have the value of the request's message ID. |
Always? Only sometimes.. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Dec 22, 2009 9:48 pm Post subject: Re: Issue with JMSmessageID on Reply to Queue |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
mvic wrote: |
fjb_saper wrote: |
In JMS the Correlation Id will have the value of the request's message ID. |
Always? Only sometimes.. |
And certainly if both partners are JMS?
Ok I have not tried to play around with the specific bits that need to be set to drive this behavior, but my understanding is that those require IBM specific targeted code and not standard JMS.
AFAIK standard JMS does not allow you to set the messageId. So the next best way is for the reply message to pass the identifier on the correlation Id...
Like suggested above the expected JMS behavior is:
if correlation id is set on request message, move to correlation id of response.
if correlation id is not set on request message move message id to correlation id of response...
Now if you have a JMS partner and a non JMS partner all bets are off and you need to check for what the specific behavior of the service provider is...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|