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 » how caon i assign correlation id to response maessage

Post new topic  Reply to topic
 how caon i assign correlation id to response maessage « View previous topic :: View next topic » 
Author Message
paolone
PostPosted: Wed Apr 28, 2010 12:46 am    Post subject: how caon i assign correlation id to response maessage Reply with quote

Newbie

Joined: 26 Apr 2010
Posts: 8

Hi, i'm trying to assign the correlation id to a response message.


MQMessage queueMessage = new MQMessage();
queueMessage.WriteString(messqaggio);
queueMessage.Format = MQC.MQFMT_STRING;
queueMessage.MessageType = MQC.MQMT_REQUEST;
queueMessage.Report = MQC.MQMO_MATCH_CORREL_ID;
queueMessage.ReplyToQueueManagerName = queueManagerName;
queueMessage.ReplyToQueueName = ResponseQueueName;


MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions();
queuePutMessageOptions.Options = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;
this.RequestQueue.Put(queueMessage, queuePutMessageOptions);


MQMessage queueMessageResp = new MQMessage();
queueMessageResp.CorrelationId = queueMessage.MessageId;

MQGetMessageOptions queueGetMessageOptions = new MQGetMessageOptions();
queueGetMessageOptions.MatchOptions = MQC.MQMO_MATCH_CORREL_ID;
queueGetMessageOptions.Options = MQC.MQGMO_WAIT;
queueGetMessageOptions.WaitInterval = 4 * 1000;

this.ResponseQueue.Get(queueMessageResp, queueGetMessageOptions);

if (queueMessage.Format.CompareTo(MQC.MQFMT_STRING) == 0)
{
result = queueMessageResp.ReadString(queueMessageResp.MessageLength);
}


the problem is that the correlationID of the response message is not set to the message id value of the request message...

any suggestion?
thanks
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Wed Apr 28, 2010 1:59 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

i am not a java guru, but

Quote:
queuePutMessageOptions.Options = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;


MQRO_COPY_MSG_ID_TO_CORREL_ID is a report option, not a put message option.

in addition i do not see any error handling and other stuff. maybe its in your code but you dont show it? is this all one program or multiple programs? do you use syncpointing and maybe response message is not committed? ....


i'd go this way:

test 1 - create a request message (verify message is there)

test 2 - read the request message and create a response message (verify response message is created and that correlid matches the msgid of the ruequest message)

test 3 - read the response message wioth the specific correlid.
_________________
Regards, Butcher
Back to top
View user's profile Send private message
paolone
PostPosted: Wed Apr 28, 2010 2:10 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2010
Posts: 8

Mr Butcher wrote:
i am not a java guru, but

Quote:
queuePutMessageOptions.Options = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;


MQRO_COPY_MSG_ID_TO_CORREL_ID is a report option, not a put message option.

in addition i do not see any error handling and other stuff. maybe its in your code but you dont show it? is this all one program or multiple programs? do you use syncpointing and maybe response message is not committed? ....


i'd go this way:

test 1 - create a request message (verify message is there)

done!

test 2 - read the request message and create a response message (verify response message is created and that correlid matches the msgid of the ruequest message)

done but the correlid doesn't match the msgid!!!!

test 3 - read the response message wioth the specific correlid.


how can i read the message with the specific id?


thanks a lot for replay Mr Butcher.
i'm a little bit confused with MQ because i'have just a little experience.
I try to explain the situation.

I'm trying to put a messege on a request queue and to retive the response. The put work and the get also. but i can't get the right response, i get the first message on the response queue not the response correlated to the request.
I suppose there is something wrong in the association of correlation id between rqqMessage and respMessage in my code:


using (this.queueManager = new MQQueueManager(this.queueManagerName, channelName, connectionName))
{

this.RequestQueue = queueManager.AccessQueue(this.RequestQueueName, MQC.MQOO_OUTPUT | MQC.MQOO_FAIL_IF_QUIESCING);
this.ResponseQueue = queueManager.AccessQueue(this.ResponseQueueName, MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING);

MQMessage queueMessage = new MQMessage();
queueMessage.WriteString(messqaggio);
queueMessage.Format = MQC.MQFMT_STRING;
queueMessage.MessageType = MQC.MQMT_REQUEST;
queueMessage.Report = MQC.MQMO_MATCH_CORREL_ID;

queueMessage.ReplyToQueueManagerName = this.queueManagerName;
queueMessage.ReplyToQueueName = this.ResponseQueueName;


MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions();
queuePutMessageOptions.Options = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;

this.RequestQueue.Put(queueMessage, queuePutMessageOptions);//
MQMessage queueMessageResp = new MQMessage();
queueMessageResp.CorrelationId = queueMessage.MessageId;



MQGetMessageOptions queueGetMessageOptions = new MQGetMessageOptions();
queueGetMessageOptions.MatchOptions = MQC.MQMO_MATCH_CORREL_ID;
queueGetMessageOptions.Options = MQC.MQGMO_WAIT;
queueGetMessageOptions.WaitInterval = 4 * 1000;


this.ResponseQueue.Get(queueMessage, queueGetMessageOptions);
result = queueMessage.ReadString(queueMessage.MessageLength);




//Close the queue
this.RequestQueue.Close();
this.ResponseQueue.Close();

// Disconnect from the queue manager
this.queueManager.Disconnect();

}


thanks for your help!
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Wed Apr 28, 2010 2:47 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

again, i can not help much with java.

1. i repeat myself - that MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID is a report option, not a put message option.

2. to read the response you do

MQMessage queueMessageResp = new MQMessage();
queueMessageResp.CorrelationId = queueMessage.MessageId;

but then you get the message with

this.ResponseQueue.Get(queueMessage, queueGetMessageOptions);


shouldn't that read

this.ResponseQueue.Get(queueMessageResp, queueGetMessageOptions);

?!?
_________________
Regards, Butcher
Back to top
View user's profile Send private message
paolone
PostPosted: Wed Apr 28, 2010 2:59 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2010
Posts: 8

i'm sorry, i changed the code as you made me notice in the last post.

MQMessage queueMessage = new MQMessage();
queueMessage.WriteString(messqaggio);
queueMessage.Format = MQC.MQFMT_STRING;
queueMessage.MessageType = MQC.MQMT_REQUEST;
queueMessage.Report = MQC.MQRO_COPY_MSG_ID_TO_CORREL_ID;

queueMessage.ReplyToQueueManagerName = this.queueManagerName;
queueMessage.ReplyToQueueName = this.ResponseQueueName;


MQPutMessageOptions queuePutMessageOptions = new MQPutMessageOptions();

this.RequestQueue.Put(queueMessage, queuePutMessageOptions);


MQMessage queueMessageResp = new MQMessage();

queueMessageResp.CorrelationId = queueMessage.MessageId;

queueMessageResp.MessageType = MQC.MQMT_REPLY;

MQGetMessageOptions queueGetMessageOptions = new MQGetMessageOptions();
queueGetMessageOptions.MatchOptions = MQC.MQMO_MATCH_CORREL_ID;
queueGetMessageOptions.Options = MQC.MQGMO_WAIT;
queueGetMessageOptions.WaitInterval = 4 * 1000;

this.ResponseQueue.Get(queueMessageResp, queueGetMessageOptions);
result = queueMessageResp.ReadString(queueMessageResp.MessageLength);



ok, this is the corrected code. Anywhere the problem persists.
This code works fine if i comment the bold line (where i try to assign correl id = messageid). But not so fine because i get the first message, not the correlated....


thanks a lot
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Wed Apr 28, 2010 4:06 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

? the code works fine if you try to get without thje correlid? but if you try to get with correlid, it does nto work? what do you get? 2033? did you make sure the message is in the queue?
_________________
Regards, Butcher
Back to top
View user's profile Send private message
paolone
PostPosted: Wed Apr 28, 2010 4:32 am    Post subject: Reply with quote

Newbie

Joined: 26 Apr 2010
Posts: 8

yes, i get 2033 (no message available). anyway the message is in the queue but with with correlationid=0 and his own (unic) messageid...

i don't understand why...
thanks Mr Butcher
Back to top
View user's profile Send private message
Mr Butcher
PostPosted: Wed Apr 28, 2010 5:01 am    Post subject: Reply with quote

Padawan

Joined: 23 May 2005
Posts: 1716

well, then check the response-creating application.
_________________
Regards, Butcher
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Apr 28, 2010 5:08 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

This is almost a double post of this

We're not a training resource, not are we equipted to walk you through your first Java WMQ app no matter how much you want to be helpful to your company.
_________________
Honesty is the best policy.
Insanity is the best defence.
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 » how caon i assign correlation id to response maessage
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.