Author |
Message
|
radiatejava |
Posted: Wed Nov 21, 2007 6:00 am Post subject: JMSReplyTo coming as null for response processing |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
I am having my application that sends JMS messages to a MQ topic T1. Messages sent to the topic have the JMSReplyTo information set. Another subscriber application is also JMS (subscribing to T1) but not using JNDI for factory lookups etc. I am using WMQ 6.0.
Two Problems:
1. When the subscriber receives the message it does not have the JMSReplyTo info available, it comes as null.
Message published to topic T1:
JMS Message class: jms_text
JMSType: text/plain; charset=utf-8
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: null
JMSTimestamp: 0
JMSCorrelationID:MEC-ID-1195630616001-5-5;AAAAAAEWYSOTcwAABQAAAAAH
JMSDestination: null
JMSReplyTo: topic://sp_reply
JMSRedelivered: false
AONS_ERROR_DESC:OK
AONS_ERROR_CODE:200
Message received by the subscriber:
JMS Message class: jms_bytes
JMSType: null
JMSDeliveryMode: 1
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d5120514d312020202020202020209ab32847911a0020
JMSTimestamp: 1195653128220
JMSCorrelationID:ID:414d5120514d312020202020202020209ab3284704190920
JMSDestination: null
JMSReplyTo: null
JMSRedelivered: false
JMSXDeliveryCount:1
JMS_IBM_MsgType:8
JMSXAppID:QM1
JMS_IBM_Format:
JMS_IBM_Encoding:273
JMS_IBM_PutApplType:26
JMS_IBM_Character_Set:UTF8
JMSXUserID:mqm
JMS_IBM_PutTime:13520822
JMS_IBM_PutDate:20071121
2. As you see, the message published was TextMessage but what subscriber receives is BytesMessage.
The publisher is using pure JNDI/JMS APIs. Subscriber is not using JNDI instead it is using something like this:
MQTopicConnectionFactory factory = new MQTopicConnectionFactory();
factory.setHostName(hostName);
factory.setChannel(ch);
factory.setQueueManager(qm);
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
factory.setPort(port);
connection = factory.createTopicConnection();
subSession = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
pubSession = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
subTopic = subSession.createTopic(sub_topic);
connection.start();
Can anyone tell me whats wrong I am doing? Why is the replyTo info coming as null. And why BytesMessage instead of TextMessage? Help is appreceiated.
Thanks
-Satish |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Nov 21, 2007 12:11 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Why would you want a reply to info on a pub/sub.
The premise of pub/sub is that there is no link between publishers and subscribers. If you need a request/reply scenario you should do p2p.
This being said there is no proof that the message received was the message published.... so where do you move from a TextMessage to a BytesMessage?? I would suggest that 2 messages got published a BytesMessage and a TextMessage. You received correctly one and rejected the other...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
radiatejava |
Posted: Wed Nov 21, 2007 9:16 pm Post subject: |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
you might be true but my question - can we not do this using pub/sub model? Also, the msg being published is always TextMessage but what is received is always BytesMessage. My application is still not in production but in testing phase where we are testing with TextMessage now.
Thanks
-Satish |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 22, 2007 1:34 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
radiatejava wrote: |
you might be true but my question - can we not do this using pub/sub model? |
The point of pub/sub (to underline the point made by fjb_saper) is that there's no connection between publisher and subscriber. If you're looking for a reply then this implies that the publisher knows who is subscribing and what reply they will be sending. What would happen (in your scenario) if another subscriber picked up the topic? Would you get, or expect, 2 replies?
IMHO the question is not can this be done with pub/sub but why are you trying to do it with pub/sub? What are your requirements and why do you believe pub/sub meets them? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
radiatejava |
Posted: Thu Nov 22, 2007 3:40 am Post subject: |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
Actually, upon testing further, I see that same is the result with queues also - ie, when a TextMessage is sent to a queue Q1, the listenr to the queue Q1:
a) receives a BytesMessage (expected is TextMessage)
b) replyTo field is missing. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 22, 2007 4:16 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
a) You're certain it's being sent as a text message not a byte message (not intended to be sent as a text message or believed to be a text message but configured as a text message and put to the queue as such)
b) You're certain the reply to queue is being set prior to the message being sent (not intended to be set or believed to be set but configured prior to send and put to the queue with it in place) _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
radiatejava |
Posted: Thu Nov 22, 2007 4:56 am Post subject: |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
Please take a look at my first post. I am printing the msg that is being sent just prior to sending and also printing what the receiver is getting just after getting the msg. Putting again:
Message published to topic T1:
JMS Message class: jms_text
JMSType: text/plain; charset=utf-8
JMSDeliveryMode: 2
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: null
JMSTimestamp: 0
JMSCorrelationID:MEC-ID-1195630616001-5-5;AAAAAAEWYSOTcwAABQAAAAAH
JMSDestination: null
JMSReplyTo: topic://sp_reply
JMSRedelivered: false
AONS_ERROR_DESC:OK
AONS_ERROR_CODE:200
Message received by the subscriber:
JMS Message class: jms_bytes
JMSType: null
JMSDeliveryMode: 1
JMSExpiration: 0
JMSPriority: 4
JMSMessageID: ID:414d5120514d312020202020202020209ab32847911a0020
JMSTimestamp: 1195653128220
JMSCorrelationID:ID:414d5120514d312020202020202020209ab3284704190920
JMSDestination: null
JMSReplyTo: null
JMSRedelivered: false
JMSXDeliveryCount:1
JMS_IBM_MsgType:8
JMSXAppID:QM1
JMS_IBM_Format:
JMS_IBM_Encoding:273
JMS_IBM_PutApplType:26
JMS_IBM_Character_Set:UTF8
JMSXUserID:mqm
JMS_IBM_PutTime:13520822
JMS_IBM_PutDate:20071121 |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Nov 22, 2007 5:08 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I just used mqjmspub.java and mqjmssub.java from:
http://www-304.ibm.com/jct09002c/isv/tech/sampmq.html
I started a durable subscriber and then ended it (without deregistering) so that I could browse the message queue. Here is part of my output:
Code: |
00000070: 6420 5075 626C 6973 6820 4D51 5053 546F 'd Publish MQPSTo'
00000080: 7069 6320 7465 7374 696E 6720 4D51 5053 'pic testing MQPS'
00000090: 5075 624F 7074 7320 4E6F 5265 6720 2020 'PubOpts NoReg '
000000A0: 5246 4820 0000 0002 0000 0098 0000 0111 'RFH ............'
000000B0: 0000 04B8 4D51 5354 5220 2020 0000 0000 '...╕MQSTR ....'
000000C0: 0000 04B8 0000 0020 3C6D 6364 3E3C 4D73 '...╕... <mcd><Ms'
000000D0: 643E 6A6D 735F 7465 7874 3C2F 4D73 643E 'd>jms_text</Msd>'
000000E0: 3C2F 6D63 643E 2020 0000 004C 3C6A 6D73 '</mcd> ...L<jms'
000000F0: 3E3C 4473 743E 746F 7069 633A 2F2F 7465 '><Dst>topic://te'
00000100: 7374 696E 673C 2F44 7374 3E3C 546D 733E 'sting</Dst><Tms>' |
Inside my message, I see the jms_text. I'd suggest that you try looking at the actual queue where the subscription resides. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 22, 2007 5:12 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Yes, but the reply to queue in your put message is a topic not a queue. I thought you said you'd seen the same result with queues?
So it's sent as a text message. Are you certain (not intending or believing) it's being retrieved as a text message not as a byte array (or whatever the correct Java term is)? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Nov 22, 2007 5:15 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
For what it is worth, here is the reply to queue/qmgr from the previous message:
Code: |
ReplyToQ : ' '
ReplyToQMgr : 'pubsub.qmgr ' |
I'm using amqsbcg to look at my subscriber's messages on the queue. I'm not using a java subscriber to pick them up and dump them. |
|
Back to top |
|
 |
radiatejava |
Posted: Thu Nov 22, 2007 5:21 am Post subject: |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
I had mentioned in the first post itself that the subscriber or the receiver is not based on JNDI lookups. When I use JNDI to do lookups, msgs are received correctly with ReplyTo and TextMessage type. But when I use this API (which is not JNDI) to get the factory, connection etc, there is a problem. This is what I do in the subscriber:
The publisher is using pure JNDI/JMS APIs. Subscriber is not using JNDI instead it is using something like this:
MQTopicConnectionFactory factory = new MQTopicConnectionFactory();
factory.setHostName(hostName);
factory.setChannel(ch);
factory.setQueueManager(qm);
factory.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
factory.setPort(port);
connection = factory.createTopicConnection();
subSession = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
pubSession = connection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
subTopic = subSession.createTopic(sub_topic);
connection.start(); |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 22, 2007 5:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Look up the MQTopicConnectionFactory class. Your initialization is sufficient for a qcf but lacks crucial information for a tcf.
Read the using java manual.  _________________ MQ & Broker admin |
|
Back to top |
|
 |
radiatejava |
Posted: Thu Nov 22, 2007 6:18 am Post subject: |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 22, 2007 10:52 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
The TCF as created in the example you are providing assumes a lot of things that I am not sure apply to your environment.
Lookup the class MQTopicConnectionFactory and it's methods in detail reading the Using Java manual. This will be more precise and tell you more than my failing memory...
You might also look in the info center for the pub/sub manual
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
radiatejava |
Posted: Thu Nov 29, 2007 9:16 pm Post subject: |
|
|
Novice
Joined: 21 Nov 2007 Posts: 17
|
No luck yet to me.. I am yet to see a TextMessage by the subscriber when the publisher puts a TextMessage. Thanks in advance again.
Last edited by radiatejava on Thu Nov 29, 2007 11:52 pm; edited 1 time in total |
|
Back to top |
|
 |
|