|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
JMS : report options |
« View previous topic :: View next topic » |
Author |
Message
|
srk |
Posted: Wed Mar 28, 2007 6:47 am Post subject: JMS : report options |
|
|
Newbie
Joined: 28 Mar 2007 Posts: 2
|
Hi ,
I am writing a JMS application which sends a messages to a native appliaction, therefore i have to set the target client to JMSC.MQJMS_CLIENT_NONJMS_MQ (in order to supress the MQRFH2 headers).
My application expects to get a report back on arrival. Therefore
in my message I set the following properties
outMessage.setJMSCorrelationID("Msg-1"); // setting the correlation Id
// setting the report options
outMessage.setIntProperty("JMS_IBM_Report_COA", 1792 ); outMessage.setIntProperty("JMS_IBM_Report_Pass_Correl_ID",64); // To pass the correlation id of the request msg back
When I get the report message back my correlation id is NOT what I expect. However when I browse the report messages on my replyto queue (using MQExplorer) I can see that the correlation ID is set correctly to "Msg-1". But when I read the correlation Id programatically using getJMSCorrelationID() i get a generated hex value.
As per the MQ spec the JMSCorrelation Id is mapped to MQMD correlaId
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp?topic=/com.ibm.mq.csqzaw.doc/csqzaw1481.htm
pasting the relevant code below
----------------------------------------
code:
------------- -------------------------------------------------------------------
facto ry = new MQQueueConnectionFactory();
MQQueueConnectionFactory)factory).setQueueManage r(QMGR);connection = factory.createQueueConnection();
connection.start();boolean transacted = false;
session = connection.createQueueSession( transacted, Session.AUTO_ACKNOWLEDGE);ioQueue = session.createQueue( QUEUE );((com.ibm.mq.jms.MQQueue)ioQueue).setTargetClient(JMSC.MQJMS_CLIENT_NONJMS_MQ );
QueueSender queueSender = session.createSender(ioQueue);
TextMessage outMessage = session.createTextMessage("Hello");
outMessage.setJMSCorrelationID("ProcessC ontrolMsg-1");
outMessage.setIntProperty("JMS_IBM_Report_COA", 1792 );
outMessage.setIntProperty("JMS_IBM_Report_Pass_Correl_ID",64);
Queue reply = session.createQueue("DUMMY");outMessage.setJMSReplyTo(reply);
queueSender.se nd(outMessage);
QueueReceiver queueReceiver = session.createReceiver(reply);
Message inMessage = queueReceiver.receive(0);
System.out.println("Correl ID " + ((TextMessage)inMessage).getJMSCorrelationID());
----------------------------------------------------------------------- ---------
Any help would be much appreciated.
Thanks
srk |
|
Back to top |
|
 |
Vitor |
Posted: Wed Mar 28, 2007 6:56 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
There are many, many threads on this board about the dangers of a) setting either msg id or correlation id, and b) treating them as strings.
They are byte arrays not strings.
Use of the search function will yield a wealth of discussion, including other ways of meeting your requirements. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Mar 28, 2007 1:46 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Quote: |
When I get the report message back my correlation id is NOT what I expect. However when I browse the report messages on my replyto queue (using MQExplorer) I can see that the correlation ID is set correctly to "Msg-1". But when I read the correlation Id programatically using getJMSCorrelationID() i get a generated hex value. |
Just proves to say working as designed and you do have the right value.
If you retrieve the correlId as bytes and take the relevant bytes to make a String you will see that it matches...
Now I cannot stress enough Vitor's post.
There is a SIGNIFICANT performance hit in treating correlId as a String when using JMS: correlId = "mystring".
This is why you should always use the native (provider) form (correlId = "ID:xxxxxxxx"). (the value of the bytes can be "mystring" when passed to a String constructor...) This gives you a hex representation of the byte array and is way faster than the previous view. It is also way more reliable as it allows for byte values that are outside the char values... (standard MQ correlId is really a byte[24])
And remember this is an anonymous identifier pattern...
Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
srk |
Posted: Thu Mar 29, 2007 8:23 am Post subject: |
|
|
Newbie
Joined: 28 Mar 2007 Posts: 2
|
Thanks that helped !!
Cheers |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|