Author |
Message
|
meetgaurav |
Posted: Tue Nov 04, 2008 6:30 am Post subject: Problem In MQ MessageID |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
HI
Am just trying to set the message ID to the Message before putting it into the Queue. But the Message Id will be over ridded by Qmgr I guess.
My Application is an MDB running in OC4J
TextMessage message = session.createTextMessage(mess);
message.setJMSMessageID("SATYAM");
message.setJMSCorrelationID("SATYAM Computers");
sender.send(message, delMode, messPriority, expTime);
System.out.println("Message ID=>" +message.getJMSMessageID());
System.out.println("CORREL ID=>" +message.getJMSCorrelationID());
After putting the message in the Websphere MQ Queue. I just printed it
Message ID=>ID:414d5120464c45584d4c5f58415f4a41490834cf2007e904
CorrelationID=>SATYAM Computers
Please assist Me. I want to Set the Message Id for all Out going Messages..
One of my Friend is tried in C pgm and this is working.. |
|
Back to top |
|
 |
meetgaurav |
Posted: Tue Nov 04, 2008 6:51 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
Now I know the use of set jms Message ID
setJMSMessageID
public void setJMSMessageID(String id)
throws JMSExceptionSets the message ID.
JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.
Is there any Other way to set the message ID for my Message. Am not using MQMessage, Here am using JMS..
Please Assist Me |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Nov 04, 2008 6:54 am Post subject: Re: Problem In MQ MessageID |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
meetgaurav wrote: |
Message ID=>ID:414d5120464c45584d4c5f58415f4a41490834cf2007e904
CorrelationID=>SATYAM Computers |
FYI...The correlation and message id's are not converted by WMQ when messages are sent to different platforms. You might find trouble down the road by putting a 'string' into one of these fields. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 04, 2008 7:02 am Post subject: Re: Problem In MQ MessageID |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
meetgaurav wrote: |
Please assist Me. I want to Set the Message Id for all Out going Messages..
|
No you don't. This is a very bad idea which has been discussed a lot of the forum.
You also don't want to set the correlation id to anything which isn't a message id or something related to it. Certainly not to a string of business information. This is not what the correlation id is intended for and will lead you to problems.
Just because your friend has succeeded in doing this in C doesn't mean he should be doing it either. It's a flawed design. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
meetgaurav |
Posted: Tue Nov 04, 2008 7:09 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
HI
Thanks for UR reply...But for me this is a requirement. Another remote system will identify the message using the Message Id only..
So No other way to change the design At the last Time..
Even I tried to create MQMessage and set the message Id and then cast to Message. But its not worked out..
Any Other way to set the Message Id. please suggest, Its very Urgent
Last edited by meetgaurav on Tue Nov 04, 2008 9:17 am; edited 1 time in total |
|
Back to top |
|
 |
bower5932 |
Posted: Tue Nov 04, 2008 9:16 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
CorrelExample.java at http://www-304.ibm.com/jct09002c/isv/tech/sampmq.html#java sets correlation and message id's so that you can see how selectors work.
I'll second Vitor and say that you shouldn't be using the message id and correlation id to store your application data. If you are still writing your code, then I'd suggest you go back to the remote half of your application and figure out another way to do what you want. |
|
Back to top |
|
 |
meetgaurav |
Posted: Tue Nov 04, 2008 9:22 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
HI
I already seen this link and there is no example for JMS type. Only MQ Java example is there to set the messageID..
Another other suggestions |
|
Back to top |
|
 |
PeterPotkay |
Posted: Tue Nov 04, 2008 10:11 am Post subject: |
|
|
 Poobah
Joined: 15 May 2001 Posts: 7722
|
You can't do what you want in JMS. And to repeat what others have said, you shouldn't do this anyway.
http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/topic/com.ibm.mq.csqzaw.doc/uj26770_.htm
Quote: |
public void setJMSMessageID(String id) throws JMSException;
Sets the message ID.
Any value set using this method is ignored when the message is sent, but this method can be used to change the value in a received message.
Because a message ID set by this method is ignored when a message is sent, an application cannot specify the message ID of an outgoing message. As a consequence, an application cannot receive a message and then forward the same message, or send a different message, with the same message ID as that of the message it has received. The behavior of WebSphere MQ classes for Java differs in this respect. An application using WebSphere MQ classes for Java can specify the message ID of an outgoing message
|
_________________ Peter Potkay
Keep Calm and MQ On |
|
Back to top |
|
 |
Vitor |
Posted: Tue Nov 04, 2008 11:00 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
meetgaurav wrote: |
Thanks for UR reply...But for me this is a requirement. Another remote system will identify the message using the Message Id only..
|
There are so many other ways the remote system could identify a message that don't involve setting message id it's not funny.
The example you quoted earlier set correl id which is bad. If you're setting message id, and setting it to identical values in more than one message, you are going to hit problems. The queue manager expects message id to be unique, and gets unhappy when it isn't. How unhappy & when depends on how you're set up.
Do not do this. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
atheek |
Posted: Tue Nov 04, 2008 3:05 pm Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
If your receiver app is JMS, explore the possibilities of using RFH2 headers. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Nov 04, 2008 3:49 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
meetgaurav wrote: |
HI
I already seen this link and there is no example for JMS type. Only MQ Java example is there to set the messageID..
Another other suggestions |
In JMS the PROVIDER sets the JMSMessageId when the send method is called. YOU have NO control over it. NOR should you rely on any information of any value in it.
If you need to pass information look either at the RFH header (message properties) or at fields like correlationId and groupId.
However be aware that these fields need to be evaluated as byte[] and in no way should be looked at as strings as they will not get converted from one CCSID to another...
And remember that for efficient processing of the message selector you need to restrict yourself to msgid, correlid, groupid and use the provider specific form or you need to use MQ V7!!!
Review your design! . Enjoy  _________________ MQ & Broker admin |
|
Back to top |
|
 |
meetgaurav |
Posted: Tue Nov 04, 2008 7:42 pm Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
Any way to set the message Id in Payload ???
How to use RFH2 headers ?? |
|
Back to top |
|
 |
atheek |
Posted: Tue Nov 04, 2008 9:37 pm Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
You can set app specific jms properties ( using msg.setXXXProperty())
which will be mapped to usr folder of the RFH2 header.
Eg.
TextMessage m = session.createTextMessage();
msg.setStringProperty("Company","SATYAM");
The receiving jms applicaion can use message selectors to get the messages they are interested in. The message selectors can be passed as an arguement to Session.createConsumer() method
Eg.
MessageConsumer receiver = session.createConsumer(q,"Company='SATYAM'");
Ensure the JMS destination queue has TARGCLIENT(JMS) set. |
|
Back to top |
|
 |
meetgaurav |
Posted: Sat Nov 15, 2008 12:39 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
I heard that there an API to set the message ID. Could someone please assist me, How to use that??...
Am going to set the message id which is generated by QMGR while replying to the remote machine for the same message. So it should be unique. |
|
Back to top |
|
 |
atheek |
Posted: Sat Nov 15, 2008 1:25 am Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
What is your requirement? Is it for a request reply scenario?
The pattern is to use the messageId in the request as the correlation id in the reply. The requester application after sending the request should wait for the reply message with a matching correlation id as the message id in the request. The server application which process the request should set the correlation id field in the reply to be same as the message id in the request.
Sample code link above has an example mqjmssrv.java which shows how to do this. |
|
Back to top |
|
 |
|