ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Note getting response of correlated request

Post new topic  Reply to topic
 Note getting response of correlated request « View previous topic :: View next topic » 
Author Message
rahul13.p
PostPosted: Mon Dec 23, 2013 8:00 am    Post subject: Note getting response of correlated request Reply with quote

Newbie

Joined: 23 Dec 2013
Posts: 4

Hi All

I am using MQ for synchronous communication with external application.I have written below code for same but I am not getting the response based on the correlation id or message id of request that I am putting in queue.
Appreciate your valuable inputs as I am struggling with this issue since many days.

Code:

MQEnvironment.hostname="<host ip>";
MQEnvironment.channel="<MQ environment>";
MQEnvironment.port=MQ port
try{

MQQueueManager qMgr= new MQQueueManager(queue manager name);

MQQueue inputQueue = qMgr.accessQueue("request queue name",MQC.MQOO_OUTPUT);

MQMessage sampleRequest = new MQMessage();

sampleRequest.writeString(sampleXmlRequest);

  MQPutMessageOptions pmo = new MQPutMessageOptions();

  sampleRequest.replyToQueueManagerName=Queue manager name;

sampleRequest.replyToQueueName="response queue name";

 inputQueue.put(sampleRequest, pmo);

 MQMessage sampleResponse = new MQMessage();

sampleResponse.correlationId=sampleRequest.correlationId;

 MQGetMessageOptions gmo = new MQGetMessageOptions();
           
            gmo.matchOptions=MQC.MQMO_MATCH_CORREL_ID;
            gmo.waitInterval=7000;
            gmo.options=MQC.MQGMO_WAIT;

MQQueue outputQueue = qMgr.accessQueue("response queue name", MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT);

 outputQueue.get(sampleResponse, gmo);

 String msgtext = sampleResponse.readStringOfCharLength(sampleResponse.getMessageLength());

outputQueue.close();
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Dec 23, 2013 5:21 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

Well is the other application sending anything back?
Can you see any responses being sent your way? (WMQExplorer)...
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rahul13.p
PostPosted: Mon Dec 23, 2013 9:24 pm    Post subject: Reply with quote

Newbie

Joined: 23 Dec 2013
Posts: 4

@fjb_saper

Another application is sending response messages back when I am doing "outputQueue.get(sampleResponse, gmo); ". but the message is not of the corelated request. It seems whichever older message found in output queue,that message is returns.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Tue Dec 24, 2013 7:44 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20696
Location: LI,NY

This could be a timing problem. Remember that with WMQ your message is not available to the other party or even the channel) until committed. You need to look at your transaction boundaries...
And please remember that your request response pattern requires at least 2 transactions.

Remember as well that if you use JMS and an appserver the appserver's transaction might / will supersede the JMS transaction settings...

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rahul13.p
PostPosted: Wed Dec 25, 2013 8:34 am    Post subject: Reply with quote

Newbie

Joined: 23 Dec 2013
Posts: 4

But this is standard code to achieve synchronous communication in MQ. I am not getting why it is not working.

If I am retrieving the message from response queue by correlation id then it should give me that message only.
Back to top
View user's profile Send private message
smdavies99
PostPosted: Wed Dec 25, 2013 10:12 pm    Post subject: Reply with quote

Jedi Council

Joined: 10 Feb 2003
Posts: 6076
Location: Somewhere over the Rainbow this side of Never-never land.

As my colleague says there you have to be aware of the various transaction boundaries.
Are you sure that you are really committing the outbound message?
The message may have been written to the queue but until it is comittend then no one else can read it.

IF that is ok, try removing the CORRELID Match and display the ID's received. The destination app could be mangling the copy of the CORREID it receives to the outbound CORRELID
_________________
WMQ User since 1999
MQSI/WBI/WMB/'Thingy' User since 2002
Linux user since 1995

Every time you reinvent the wheel the more square it gets (anon). If in doubt think and investigate before you ask silly questions.
Back to top
View user's profile Send private message
rahul13.p
PostPosted: Thu Dec 26, 2013 5:44 am    Post subject: Reply with quote

Newbie

Joined: 23 Dec 2013
Posts: 4

Issue get resolved by just making below code change

sampleResponse.correlationId=sampleRequest.messageId;


Now I am getting message related to request only.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Note getting response of correlated request
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.