Author |
Message
|
sebastia |
Posted: Sun Dec 22, 2013 8:51 am Post subject: JMS mq client connected via CCDT - how to know qmgr name |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Hi. We are using pure JMS, and our code connects to 2 qmgr using CCDT.
Works fine, but I want to know the name of the qmgr where we are connected at a given time.
What method shall I use ?
Thanks. Sebastian.
Code folows
Code: |
String szTAB = "C:/MQ/CCDT_test/ESTEVE.TAB" ;
String szNomCuaEntrada = "ENTRADA" ;
cf = new MQQueueConnectionFactory() ;
java.net.URL chanTab1 = new URL( "file:///"+ szTAB ) ;
cf.setCCDTURL(chanTab1);
my_MQ_queue_connection = (MQQueueConnection) cf.createQueueConnection();
my_MQ_queue_session = (MQQueueSession) my_MQ_queue_connection.createQueueSession( false, Session.AUTO_ACKNOWLEDGE ) ;
my_MQ_queue = (MQQueue) my_MQ_queue_session.createQueue("queue:///" + szNomCuaEntrada );
===
Thankx !!!
|
|
|
Back to top |
|
 |
fjb_saper |
Posted: Sun Dec 22, 2013 8:52 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Create a request message and put to a queue. Read the request message and check out the Replyto Destination. It should have the qmgr name in it... (queue://<qmgr>/<queue>?attrib1=value1&attribn=valuen)
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
sebastia |
Posted: Mon Dec 23, 2013 4:13 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Thaks, mr Saper.
Yes, I have noticed that on the destination queue, I have the message with the field "ReplyToQueueManager" field filled properly ... but did not know if that was some kind of "colateral" effect.
My problem is ... I cant read the (cluster) queue
At what moment is this field filled up ?
The JMS application connects to a local queue manager using CCDT.
Then, it sends a message to a cluster queue, that has no local definition.
So, I can not "read" that field from the mesage in the queue.
Code: |
mensajesenviados++ ;
String t2 = String.format( "(%4.4s) " + t, mensajesenviados ) ;
JMSTextMessage message = (JMSTextMessage) my_MQ_SndQueue_session.createTextMessage( t2 ) ;
message.setJMSReplyTo( my_MQ_RcvQueue ); // posem al missatge el nom de la cua on volem la resposta
message.setJMSType( "MQSTR " ) ; //
my_MQ_sender.send( message ) ; // enviem el missatge |
Guess at the moment immediatelly PRECEDING sender.send (msg) the field shall be already set up and I can copy it .... OR NOT ?
Or maybe "message" contains The fields filled up in MD after the call, am I right ? Can I use "message.getJMSReplyToQMgr" ?
Thanks. Sebastian.
PD.- I also need to read the "Message-ID" field of the message, so I can wait for it to come back as "correl-id"
How can I do that ? |
|
Back to top |
|
 |
Michael Dag |
Posted: Mon Dec 23, 2013 5:32 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
after put/send the message.messageId and message.replyToQueueManagerName should be filled, no need to read the message back from the queue _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
sebastia |
Posted: Mon Dec 23, 2013 7:01 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
Hi, Micheal - looks like I can read MSG-ID properly !
Code: |
String t2 = String.format( "(%4.4s) " + t, mensajesenviados ) ;
JMSTextMessage message = (JMSTextMessage) my_MQ_SndQueue_session.createTextMessage( t2 ) ;
message.setJMSReplyTo( my_MQ_RcvQueue ); // write queue name
message.setJMSType( "MQSTR " ) ; // set msg type
my_MQ_sender.send( message ) ; // send the message
String myJMS_msgId = message.getJMSMessageID() ;
System.out.println( "sent msg ID [" + myJMS_msgId + "]." ) ; |
Now only ReplyToQueueManager is missing ...
Thanks ! Sebastian. |
|
Back to top |
|
 |
sebastia |
Posted: Mon Dec 23, 2013 7:12 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
fjb_saper wrote: |
Create a request message and put to a queue. Read the request message and check out the Replyto Destination. It should have the qmgr name in it... (queue://<qmgr>/<queue>?attrib1=value1&attribn=valuen)
|
mr Saper : I read the message field and find it half empty
My code is
Code: |
my_MQ_sender.send( message ) ; // enviem el missatge
String myJMS_msgId = message.getJMSMessageID() ;
System.out.println( "sent msg ID [" + myJMS_msgId + "]." ) ;
Destination myJMS_ReplyTo = message.getJMSReplyTo() ;
System.out.println( "sent ReplyTo() [" + myJMS_ReplyTo + "]." ) ; |
and the trace is
Code: |
>>> enviar_i_rebre_Missatges()
sent msg ID [ID:414d5120514d454e543120202020202017edb75220018903].
sent ReplyTo() [queue:///RESPOSTA].
( 1) payload del missatge que enviem. - s'han enviat (1) msgs i queden (2) per enviar
Lets wait (2000) mili-secs for a response. |
I mean, the queue name is there "RESPOSTA" but not the queue manager.
Any clue ? |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Dec 23, 2013 5:17 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
You need to read the field after the send method has been called on the message.
If that does not work, read the destination off the reply message. It should have the qmgr name. My thought was to put a request message on a local queue and read it right back in to get the information...
More pertinently, why do you need this information and what do you plan on doing with it?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
sebastia |
Posted: Tue Dec 24, 2013 12:30 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
After the "send" method has been called, the ReplyTo() method gives ... only the queue name, no qmgr.
The "request-response" messaging works fine, as Request has the field filled up, and AMQSECHA uses it and sends the Reply properly.
I wanted the name of the queue manager ... for tracing purposes, for statistics, for logging, for reporting to a central site.
Cheers.
Sender code :
Code: |
my_MQ_sender.send( message ) ; // enviem el missatge
String myJMS_msgId = message.getJMSMessageID() ;
System.out.println( "sent msg ID [" + myJMS_msgId + "]." ) ;
Destination myJMS_ReplyTo = message.getJMSReplyTo() ;
System.out.println( "sent ReplyTo() [" + myJMS_ReplyTo + "]." ) ; |
Available trace:
Code: |
sent msg ID [ID:414d5120514d454e5431202020202020b245b95220001f03].
sent ReplyTo() [queue:///RESPOSTA]. |
|
|
Back to top |
|
 |
Michael Dag |
Posted: Tue Dec 24, 2013 2:15 am Post subject: |
|
|
 Jedi Knight
Joined: 13 Jun 2002 Posts: 2607 Location: The Netherlands (Amsterdam)
|
are you using non-IBM jms libraries? ReplytoQmgr is not in the JMS spec itself. _________________ Michael
MQSystems Facebook page |
|
Back to top |
|
 |
sebastia |
Posted: Tue Dec 24, 2013 4:05 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
hi, Michael.
pure JMS now, no IBM
I was expecting to receive something like
Code: |
[queue://QMENT1/RESPOSTA?targetClient=1]. |
and only get
Code: |
[queue:///RESPOSTA]. |
.. with "empty" qmgr string ... |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Dec 24, 2013 8:01 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Don't know how JMS handles the JMSReplyto Destination on a Fire and Forget. However from an MQ point of view the replyto qmgr field always holds the sender qmgr information.
So if you send messages to your central location, may be it's a matter of casting the message to an MQMessage in the JMS package and extracting the information that way...
Like I said sending a request message to a local queue and reading it right back might do the trick... and you should have to do this only once per connection...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
PeterPotkay |
Posted: Tue Dec 24, 2013 9:26 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
JMS doesn't offer a way to inquire on the name of the QM object once the connection is established? I don't know, I'm asking. _________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
sebastia |
Posted: Tue Dec 24, 2013 11:12 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
on the receiving end,
where the JMS message is stored
(in a cluster queue)
I see (using MQ Explorer) ...
interesting things under "Named Properties" entry under "message properties"
===
JMSDestination = queue:///ENTRADA
JMSReplyTo = queue:///RESPOSTA
===
and under "General" entry I see
===
Reply-to-queue = RESPOSTA
Reply-t-qmgr = QMENT1
===
So, it looks to me, the field does not exist in JMS ...
In fact, "reply-to.-qmgr" is a concept that does not exist in JMS ... as someone pointed few items ago ... ( )
Best luck !
Sebastian. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Dec 25, 2013 1:47 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
sebastia wrote: |
on the receiving end,
where the JMS message is stored
(in a cluster queue)
I see (using MQ Explorer) ...
interesting things under "Named Properties" entry under "message properties"
===
JMSDestination = queue:///ENTRADA
JMSReplyTo = queue:///RESPOSTA
===
and under "General" entry I see
===
Reply-to-queue = RESPOSTA
Reply-t-qmgr = QMENT1
===
So, it looks to me, the field does not exist in JMS ...
In fact, "reply-to.-qmgr" is a concept that does not exist in JMS ... as someone pointed few items ago ... ( )
Best luck !
Sebastian. |
Haven't done it recently, but I don't quit trust MQE for this. Write a little sample prg and check the JMSreplyto property. Note that it might behave a little bit differently depending on the targetClient attribute of the destination. You might have to look at the JMS_IBM property...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
sebastia |
Posted: Wed Dec 25, 2013 2:34 am Post subject: |
|
|
 Grand Master
Joined: 07 Oct 2004 Posts: 1003
|
... mmm ... targetClient ... an interesting property ...
How do I set it ?
Is it a message property ?
Looks like "connection" property ...
Family time today ... more on friday
Best wishes for all the good people around !
Sebastian. |
|
Back to top |
|
 |
|