Author |
Message
|
martin |
Posted: Mon Apr 22, 2002 11:20 am Post subject: |
|
|
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 |
|
 |
bower5932 |
Posted: Tue Apr 23, 2002 11:41 am Post subject: |
|
|
 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 |
|
 |
martin |
Posted: Wed Apr 24, 2002 3:38 am Post subject: |
|
|
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 |
|
 |
techno |
Posted: Fri Feb 06, 2004 2:34 pm Post subject: |
|
|
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 |
|
 |
techno |
Posted: Tue Feb 10, 2004 2:33 pm Post subject: |
|
|
Chevalier
Joined: 22 Jan 2003 Posts: 429
|
|
Back to top |
|
 |
vennela |
Posted: Tue Feb 10, 2004 5:31 pm Post subject: |
|
|
 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 |
|
 |
bower5932 |
Posted: Wed Feb 11, 2004 6:17 am Post subject: |
|
|
 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 |
|
 |
techno |
Posted: Wed Feb 11, 2004 10:14 am Post subject: |
|
|
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 |
|
 |
techno |
Posted: Wed Feb 25, 2004 2:20 pm Post subject: |
|
|
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 |
|
 |
techno |
Posted: Wed Feb 25, 2004 2:50 pm Post subject: |
|
|
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 |
|
 |
EddieA |
Posted: Wed Feb 25, 2004 3:40 pm Post subject: |
|
|
 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 |
|
 |
|