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 » Setting replyto Q and QMgr in JMS message

Post new topic  Reply to topic
 Setting replyto Q and QMgr in JMS message « View previous topic :: View next topic » 
Author Message
martin
PostPosted: Mon Apr 22, 2002 11:20 am    Post subject: Reply with quote

Novice

Joined: 09 Aug 2001
Posts: 17
Location: Charlotte, NC

I'm using the MQQueueConnectionFactory variant of JMS and trying to set the Q and QMgr in the Message. I see that I can use:

public void setJMSReplyTo (Destination replyTo)

but Destination class only has:

public void setDescription(String x)

am I supposed to cram both the Q and QMgr into this string with some special convention?

thanks for any ideas,


Back to top
View user's profile Send private message
bower5932
PostPosted: Tue Apr 23, 2002 11:41 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

I did the following:

msg = qReceiver.receive(30000);
String replyString = "";
if (msg == null) {
System.out.println(" No message received");
} else {
if (msg instanceof TextMessage) {
replyString = " server response to:" + ((TextMessage)msg).getText();
} else {
replyString = " server response to non-text string";
}
System.out.println(" server reply: " + replyString);

/***************************************************/
/* Need to get the destination that the reply will */
/* go to. This destination then needs to be used */
/* to create a QueueSender to send the actual */
/* reply. Just for curiosity, print out the name */
/* of the destination. */
/***************************************************/
Destination des = msg.getJMSReplyTo();
String desQueueName = ((Queue)des).getQueueName();
System.out.println(" server replyToQ: " + desQueueName);
Queue desQueue = session.createQueue(desQueueName);
QueueSender qSender = session.createSender(desQueue);
TextMessage msg1 = session.createTextMessage();
msg1.setText(replyString);
qSender.send(msg1);
System.out.println(" reply sent...");
qSender.close();
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
martin
PostPosted: Wed Apr 24, 2002 3:38 am    Post subject: Reply with quote

Novice

Joined: 09 Aug 2001
Posts: 17
Location: Charlotte, NC

thanks,

I missed the fact that a Queue is a subInterface of Destination.

Once again, I have unfairly judged a class as an individual without examining its ancestors.
Back to top
View user's profile Send private message
techno
PostPosted: Fri Feb 06, 2004 2:34 pm    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

I looked at this sample after I created a new one.

I see that

Destination des = msg.getJMSReplyTo();
String desQueueName = ((Queue)des).getQueueName();
System.out.println(" server replyToQ: " + desQueueName);
Queue desQueue = session.createQueue(desQueueName);
QueueSender qSender = session.createSender(desQueue);

Here, only the qname is taken. How about qmgr? It seems to be doing throuugh qmgr which is already connected to.

Say QMGRA sends msg to QB at QMGRB and QMGRA asks for reply at its QA. Do we have to have alias definition of QA at QMGRB? so that sending to QA at QMGRB is literally sending the message to QA at QMGRA.

Thanks
Back to top
View user's profile Send private message
techno
PostPosted: Tue Feb 10, 2004 2:33 pm    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

any help on this?
Back to top
View user's profile Send private message
vennela
PostPosted: Tue Feb 10, 2004 5:31 pm    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Techno:

What you get from
Code:
String desQueueName = ((Queue)des).getQueueName();
is not the exact queue name. It is something like

queue://REPLYQM/REPLY.TO.QUEUE

This is in the form of JMSURI. You will have to parse this to get the QMGR name and Queue Name. If no QMGR name is specified the output of

Code:
String desQueueName = ((Queue)des).getQueueName();
would be

queue:///REPLY.TO.QUEUE

For more info on JMS URI refer to Chapter 10. Writing WebSphere MQ JMS applications Sending a message section in the Using Java Manual
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bower5932
PostPosted: Wed Feb 11, 2004 6:17 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

If you start parsing out this string to get qmgr and queue names, you are getting into MQ specific behavior in your JMS application. This could have an effect on any portability you had hoped to achieve.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
techno
PostPosted: Wed Feb 11, 2004 10:14 am    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

Even after extracting q and qmgr, do we have to open a client connection? Server connection does not work as the qmgr is on the remote machine. I am not clear what to do now.
Back to top
View user's profile Send private message
techno
PostPosted: Wed Feb 25, 2004 2:20 pm    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

I am not getting qmgrname in uri. what may be the problem?
Getting output
queue:///CLM.ECF.LP.RECV

I tried to print at sender-side also. Getting the same output before setting it to msg.

Thanks for your help.
Back to top
View user's profile Send private message
techno
PostPosted: Wed Feb 25, 2004 2:50 pm    Post subject: Reply with quote

Chevalier

Joined: 22 Jan 2003
Posts: 429

I got it. Even while setting replyToQ, using URI and creating Queue solved the problem.

While sending the reply through above output, which connection I should use? Client/Server? In case of server, remote queue definition may be mandatory? Am I correct?

Thanks
Back to top
View user's profile Send private message
EddieA
PostPosted: Wed Feb 25, 2004 3:40 pm    Post subject: Reply with quote

Jedi

Joined: 28 Jun 2001
Posts: 2453
Location: Los Angeles

No, you can still use a server. As long as MQ 'knows' how to get to the destination queue manager. One of: QM Alias, XMITQ name, default XMITQ.

Cheers,
_________________
Eddie Atherton
IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Message Broker V7.0
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 » Setting replyto Q and QMgr in JMS message
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.