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 » General Discussion » MsgId/Correlld

Post new topic  Reply to topic
 MsgId/Correlld « View previous topic :: View next topic » 
Author Message
vandana
PostPosted: Mon Dec 10, 2001 11:50 pm    Post subject: Reply with quote

Acolyte

Joined: 01 Dec 2001
Posts: 74

I have created a QM(QM_ind7)
with 2 queues ind7_local1 and
ind7_reply_queue.
A java program is triggered when i put the
message in ind7_local1 using amqsput.
the queue initially doesn't contain any
messages.
the java program is given below.
the program gets a message from ind7_local1
and puts it in ind7_reply_queue.
what is the significance of
the foll stmt :
hello_world.correlationId = retrievedMessage.messageId;
the prg puts message the reply queue
even without it?


-------------------------------------
String argqmgr,argqname;
argqmgr = "QM_ind7";
argqname = "ind7_local1";
MQQueueManager qMgr;
MQGetMessageOptions gmo=new MQGetMessageOptions();
gmo.options = MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_CONVERT|
MQC.MQGMO_ACCEPT_TRUNCATED_MSG | MQC.MQGMO_WAIT ;
gmo.waitInterval = 10000;
MQPutMessageOptions pmo=new MQPutMessageOptions();

pmo.options = MQC.MQPMO_FAIL_IF_QUIESCING |MQC.MQPMO_NEW_MSG_ID;

int gopenOptions = MQC.MQOO_INPUT_EXCLUSIVE| MQC.MQOO_FAIL_IF_QUIESCING ;

int popenOptions = MQC.MQOO_FAIL_IF_QUIESCING| MQC.MQOO_OUTPUT ;

qMgr = new MQQueueManager(argqmgr);
MQQueue inputqueue= qMgr.accessQueue(argqname, gopenOptions,null,null,null);

MQQueue system_default_local_queue = qMgr.accessQueue("ind7_reply_queue", popenOptions,null,null,null);

// start while loop to read first message and reply, then await additional messages
while (compcode != 0) {
// create the message object to read from the queue
MQMessage retrievedMessage = new MQMessage();
retrievedMessage.format==MQC.MQFMT_STRING; retrievedMessage.messageType =MQC.MQMT_REQUEST;
retrievedMessage.messageId=MQC.MQMI_NONE; retrievedMessage.correlationId=MQC.MQMI_NONE;inputqueue.get(retrievedMessage,gmo,500);
int msgsize=retrievedMessage.getDataLength();
String msgText = retrievedMessage.readString(msgsize); System.out.println("message content is: n" + msgText);
MQMessage hello_world=new MQMessage();
hello_world.format=MQC.MQFMT_STRING;
hello_world.messageType = MQC.MQMT_REPLY;

hello_world.correlationId = retrievedMessage.messageId;
hello_world.writeString(msgText); system_default_local_queue.put(hello_world,pmo);
}


_________________


[ This Message was edited by: vandana on 2001-12-10 23:51 ]
Back to top
View user's profile Send private message
zpat
PostPosted: Tue Dec 11, 2001 3:58 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5849
Location: UK

It is a convention that a server program copies the incoming message id to the reply correlation id.

This allows the requestor program to issue a MQGET with CORRELID specified, since it will know the MSGID of the request message that it sent out and can wait for its reply.

This is needed where multiple requestor programs share the same reply queue. It's not needed if they have their own queues or if you don't care about matching up replies to particular requests. However it is still a good practice to follow.

PS - Don't forget to set an expiry on the message (MQPUT) when retrieving them by Correlid (MQGET) otherwise if they are not retrieved (and are persistent) they will remain on the queue.

[ This Message was edited by: zpat on 2001-12-14 08:59 ]
Back to top
View user's profile Send private message
AlexeiSkate
PostPosted: Fri Jul 12, 2002 7:22 am    Post subject: Reply with quote

Centurion

Joined: 10 Apr 2002
Posts: 123

Hi,

I would like to ask a question on the usage of the CorrId in the Java example listed above: The Java program reads a request msg off the queue. It composes a reply msg, sets the reply msg CorrId to the request message MsgId and then sends the reply msg to a reply queue. I'm assuming that if more than one applications are listening to that same reply queue, then the application that knows the CorrId of the reply msg on the queue can retrieve that specific msg only and leave the other messages on the queue alone. My question is how does an application knows what the CorrId is ? If the msg id of the original request msg was generated automatically by the QMngr then there is no way for an application to know before hand what that id is, correct ? Is this true that in a reply/request mode, the request message MsgId has to be manually generated by the program sending the request and then the other programs that want to get the reply has to know beforehand what that manually generated MsgId/CorrId is ?
Back to top
View user's profile Send private message
bduncan
PostPosted: Fri Jul 12, 2002 7:42 am    Post subject: Reply with quote

Padawan

Joined: 11 Apr 2001
Posts: 1554
Location: Silicon Valley

No, you can still use the queue manager to automatically generate a message id for you. Because of the way the MQI API works, when you are creating your request message, you build up a MQMD structure. This may be an object, hash, etc., depending on the particular programming language you are using, but in the end, you pass this MQMD structure to the MQPUT call. If the queue manager automatically generates any fields in the MQMD for you (including msgid, correlid) these values will be filled into the appropriate fields in the MQMD structure which is still available to your application after the MQPUT succeeds. Now your application can examine the MQMD structure and see what value the queue manager put in there for the message id.
_________________
Brandon Duncan
IBM Certified MQSeries Specialist
MQSeries.net forum moderator
Back to top
View user's profile Send private message Visit poster's website AIM Address
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » MsgId/Correlld
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.