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 » CorrelationID

Post new topic  Reply to topic
 CorrelationID « View previous topic :: View next topic » 
Author Message
masteringmq
PostPosted: Mon Oct 20, 2008 2:11 am    Post subject: CorrelationID Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

I wrote the code below to put and retrieve messages from a queue. The messages will be put on a remote queue on QM1 and will travel to QM5 local queue QM1.RQSTIN. I have 5 different front end interface build using the java programming language. Each interface will talk to QM1. Now how does the application retrieving the messages in QM5 know which message belongs to which interface and how does the receiving application retrieve all messages associated with a particular interface?. Do I set the correlation ID for the messages on the sending application and at the receiving end retrieve the messages using the correlation ID?. But then how does the receiving application know the correlation ID used by the sending application?.

import com.ibm.mq.*;

public class MQSample
{
private String qManager = "QM1";

private MQQueueManager qMgr;

public static void main(String args[])
{
new MQSample();
}

public MQSample()
{
try
{
//qMgr = new MQQueueManager(qManager);
//int openOptions = MQC.MQOO_OUTPUT ;
//MQQueue MQ1_RQSTIN = qMgr.accessQueue("QM1.RQSTIN",openOptions);
//MQMessage hello_world = new MQMessage();
//hello_world.writeUTF("Hello World!");
//MQPutMessageOptions pmo = new MQPutMessageOptions();
//MQ1_RQSTIN.put(hello_world,pmo);

qMgr = new MQQueueManager("QM5");
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF ;
MQQueue MQ1_RQSTIN = qMgr.accessQueue("QM1.RQSTIN",openOptions);
MQMessage retrievedMessage = new MQMessage();
//retrievedMessage.messageId = hello_world.messageId;
MQGetMessageOptions gmo = new MQGetMessageOptions();
MQ1_RQSTIN.get(retrievedMessage,gmo);
String msg = retrievedMessage.readUTF();
System.out.println(msg);

MQ1_RQSTIN.close();
qMgr.disconnect();

}
catch (MQException ex)
{
System.out.println("A WebSphere MQ error occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode);
}
catch (java.io.IOException ex)
{
System.out.println("An error occurred whilst writing to the message buffer: " + ex);
}
}
}
Back to top
View user's profile Send private message
atheek
PostPosted: Mon Oct 20, 2008 2:14 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

Why can't you have 5 different local queues at QM5 and have the corresponding 5 remote queues at QM1? This helps to keep your interfaces isolated...
Back to top
View user's profile Send private message
masteringmq
PostPosted: Mon Oct 20, 2008 4:08 am    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

Because I intend to establish a shared queue. I know that it is possible to have 5 different local queue serving 5 different application.
Back to top
View user's profile Send private message
masteringmq
PostPosted: Mon Oct 20, 2008 6:45 am    Post subject: Reply with quote

Master

Joined: 20 Oct 2008
Posts: 200

I found the answer
Back to top
View user's profile Send private message
PeterPotkay
PostPosted: Mon Oct 20, 2008 7:50 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7722

Is it a secret? Whisper it to us, so the next person with the same problem can benefit.
_________________
Peter Potkay
Keep Calm and MQ On
Back to top
View user's profile Send private message
thomas2004
PostPosted: Thu Nov 13, 2008 6:59 am    Post subject: Reply with quote

Novice

Joined: 13 Nov 2008
Posts: 16

I have the same question
Back to top
View user's profile Send private message
amer.abugharbieh
PostPosted: Wed Nov 26, 2008 1:13 am    Post subject: Reply with quote

Newbie

Joined: 25 Nov 2008
Posts: 5

i have the same question
Back to top
View user's profile Send private message
samsam007
PostPosted: Thu Nov 27, 2008 9:21 pm    Post subject: Reply with quote

Centurion

Joined: 30 Oct 2008
Posts: 107

masteringmq wrote:
I found the answer


Hello... I have the same problem. What is your solution?
Back to top
View user's profile Send private message
atheek
PostPosted: Thu Nov 27, 2008 10:27 pm    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

It is not a good practise to mix different message types into the same queue. If the 5 front end produces 5 different message types it is better to have 5 different queues to process them.

Else if you have identical messages, you can use the correlation id to correlate the response. The receiver application need not be aware from
where the request came in.It has to just copy the message ID in the request to the correlation id in the response and send it back to replyTo Queue in the request.

The sender appln needs to wait for a response in the replyTo Q with a matching correlation id.
Even if the 5 instances of the sender appln shares the same replyTO Queue, only the original sender will wait for a matching correlation ID.
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 » CorrelationID
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.