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 » General IBM MQ Support » MQMessage Correlation ID getting changed

Post new topic  Reply to topic
 MQMessage Correlation ID getting changed « View previous topic :: View next topic » 
Author Message
mjain_mq
PostPosted: Sun Jul 14, 2013 11:30 pm    Post subject: MQMessage Correlation ID getting changed Reply with quote

Newbie

Joined: 14 Jul 2013
Posts: 6

Hi,
I have a java adapter which reads message off the queue. I am trying to access the correlation id as I need same to be logged. When I try to read the Correlation ID and convert it into string, it somehow changes the value. I think it might be because its getting converted into ASCII equivalent. Below if the piece of code. Could anyone please suggest how can I get the correlation id into string. Thanks
Code:


        byte[] msgIdBytes = message.correlationId;
        StringBuffer msgID = new StringBuffer();
        for (int i = 0; i < msgIdBytes.length; i++) {
        msgID.append(msgIdBytes[i]);
        }
        String strMsgID = msgID.toString();
Back to top
View user's profile Send private message
exerk
PostPosted: Sun Jul 14, 2013 11:51 pm    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

The CORRELID is specified as MQBYTE24, and is usually the value of the MSGID (in request/reply scenarios) so why do you want to convert it to string?
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
mjain_mq
PostPosted: Mon Jul 15, 2013 12:25 am    Post subject: Reply with quote

Newbie

Joined: 14 Jul 2013
Posts: 6

Thanks for reply exerk.....I need to pass the Correl id to another application which logs it and same is used as transaction is to identify the transactions. Is there any way we can read correlation id or Msg id as string?
Back to top
View user's profile Send private message
exerk
PostPosted: Mon Jul 15, 2013 12:29 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

mjain_mq wrote:
Thanks for reply exerk.....I need to pass the Correl id to another application which logs it and same is used as transaction is to identify the transactions. Is there any way we can read correlation id or Msg id as string?

Again, why do you want it as a string?
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
mjain_mq
PostPosted: Mon Jul 15, 2013 12:33 am    Post subject: Reply with quote

Newbie

Joined: 14 Jul 2013
Posts: 6

Ok.....There is another application called TEX. Now TEX uses the transaction ids to update the state of transaction. When client puts message to the queue, it records the transaction (using the Msg id as identifier) in TEX. Now, when ny adapter reads the message off the queue, it needs to update the transaction in TEX using the same identifier, which is Msg Id or Correl Id. So I need to convert the Correl id/Msg Id into string and pass it to TEX so that it can update the transaction. This is the design we have running for long time. Its just that I am not able to pass the Msg id as string without getting ita value changed. Thanks
Back to top
View user's profile Send private message
exerk
PostPosted: Mon Jul 15, 2013 12:35 am    Post subject: Reply with quote

Jedi Council

Joined: 02 Nov 2006
Posts: 6339

mjain_mq wrote:
Ok.....There is another application called TEX. Now TEX uses the transaction ids to update the state of transaction. When client puts message to the queue, it records the transaction (using the Msg id as identifier) in TEX. Now, when ny adapter reads the message off the queue, it needs to update the transaction in TEX using the same identifier, which is Msg Id or Correl Id. So I need to convert the Correl id/Msg Id into string and pass it to TEX so that it can update the transaction. This is the design we have running for long time. Its just that I am not able to pass the Msg id as string without getting ita value changed. Thanks

Does TEX require the CORRELID value be a string, or can it just accept the value passed to it?
_________________
It's puzzling, I don't think I've ever seen anything quite like this before...and it's hard to soar like an eagle when you're surrounded by turkeys.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jul 15, 2013 12:49 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

An MQMD.CorrelationID or MQMD.MessageId field is, as mentioned, a 24 byte long field.

MQ always treats these fields as bytes.

These bytes can happily represent a 24 character ASCII string. They can happily represent a no-more-than-24-character UNICODE string (unicode being a multibyte character set)

If you allow MQ to generate either of these IDs, they will be byte strings that do not necessarily represent valid character strings.
Back to top
View user's profile Send private message
mjain_mq
PostPosted: Mon Jul 15, 2013 12:52 am    Post subject: Reply with quote

Newbie

Joined: 14 Jul 2013
Posts: 6

Quote:

Does TEX require the CORRELID value be a string, or can it just accept the value passed to it?


TEX needs it as a string. It actually expects an XML message with transaction id as one of the tags. I need to pass the correl id in this tag.
Thanks
Back to top
View user's profile Send private message
mjain_mq
PostPosted: Mon Jul 15, 2013 1:01 am    Post subject: Reply with quote

Newbie

Joined: 14 Jul 2013
Posts: 6

Thanks mqjeff.......could you please suggest the way to get the correl id into string.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Mon Jul 15, 2013 1:03 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

it's reasonably common to treat the 24 bytes of a message id or correlation id as a 48 byte character string, where each character represents a hexadecimal encoding of half the byte.

Without taking some step to create a known mapping between 24 bytes and some character string, you have to accept that some of your string may be handled badly.

In particular, putting an MQ Message ID into an xml document without performing a translation could cause the XMl document to be come invalid and unparsable.
Back to top
View user's profile Send private message
Michael Dag
PostPosted: Mon Jul 15, 2013 2:39 am    Post subject: Reply with quote

Jedi Knight

Joined: 13 Jun 2002
Posts: 2607
Location: The Netherlands (Amsterdam)

Have you looked here: http://www.capitalware.biz/mq_code_java.html ?
_________________
Michael



MQSystems Facebook page
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General IBM MQ Support » MQMessage Correlation ID getting changed
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.