ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem In MQ MessageID

Post new topic  Reply to topic Goto page 1, 2, 3, 4  Next
 Problem In MQ MessageID « View previous topic :: View next topic » 
Author Message
meetgaurav
PostPosted: Tue Nov 04, 2008 6:30 am    Post subject: Problem In MQ MessageID Reply with quote

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
View user's profile Send private message
meetgaurav
PostPosted: Tue Nov 04, 2008 6:51 am    Post subject: Reply with quote

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
View user's profile Send private message
bower5932
PostPosted: Tue Nov 04, 2008 6:54 am    Post subject: Re: Problem In MQ MessageID Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Vitor
PostPosted: Tue Nov 04, 2008 7:02 am    Post subject: Re: Problem In MQ MessageID Reply with quote

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
View user's profile Send private message
meetgaurav
PostPosted: Tue Nov 04, 2008 7:09 am    Post subject: Reply with quote

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
View user's profile Send private message
bower5932
PostPosted: Tue Nov 04, 2008 9:16 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
meetgaurav
PostPosted: Tue Nov 04, 2008 9:22 am    Post subject: Reply with quote

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
View user's profile Send private message
PeterPotkay
PostPosted: Tue Nov 04, 2008 10:11 am    Post subject: Reply with quote

Poobah

Joined: 15 May 2001
Posts: 7716

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
View user's profile Send private message
Vitor
PostPosted: Tue Nov 04, 2008 11:00 am    Post subject: Reply with quote

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
View user's profile Send private message
atheek
PostPosted: Tue Nov 04, 2008 3:05 pm    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Tue Nov 04, 2008 3:49 pm    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20697
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
View user's profile Send private message Send e-mail
meetgaurav
PostPosted: Tue Nov 04, 2008 7:42 pm    Post subject: Reply with quote

Voyager

Joined: 08 Sep 2008
Posts: 94

Any way to set the message Id in Payload ???

How to use RFH2 headers ??
Back to top
View user's profile Send private message
atheek
PostPosted: Tue Nov 04, 2008 9:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
meetgaurav
PostPosted: Sat Nov 15, 2008 12:39 am    Post subject: Reply with quote

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
View user's profile Send private message
atheek
PostPosted: Sat Nov 15, 2008 1:25 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2, 3, 4  Next Page 1 of 4

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem In MQ MessageID
Jump to:  



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
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.