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 » How to read the correlation id

Post new topic  Reply to topic
 How to read the correlation id « View previous topic :: View next topic » 
Author Message
pras120687
PostPosted: Tue Jan 25, 2022 7:44 am    Post subject: How to read the correlation id Reply with quote

Newbie

Joined: 06 Jan 2022
Posts: 6

Hi,

I am sending correlation id in MQ headers like below

java.util.Random R1 = new Random();
byte [] corId = new byte[24];
R1.nextBytes(corId);

//

inMessage.correlationId = corId ;

but in this case when i check in IBM MQ it is coming in different way like this c756DFRTYUU. But when i print inMessage.correlationId it is showing in byte code like [B@DSER.

I want to validate like what I am sending is what i am seeing in IBM MQ. How to convert inMessage.correlationId this in to normal one like in IBM MQ.
Back to top
View user's profile Send private message
bruce2359
PostPosted: Tue Jan 25, 2022 10:56 am    Post subject: Re: How to read the correlation id Reply with quote

Poobah

Joined: 05 Jan 2008
Posts: 9396
Location: US: west coast, almost. Otherwise, enroute.

pras120687 wrote:
Hi,

I am sending correlation id in MQ headers like below

java.util.Random R1 = new Random();
byte [] corId = new byte[24];
R1.nextBytes(corId);

//

inMessage.correlationId = corId ;

but in this case when i check in IBM MQ it is coming in different way like this c756DFRTYUU. But when i print inMessage.correlationId it is showing in byte code like [B@DSER.

I want to validate like what I am sending is what i am seeing in IBM MQ. How to convert inMessage.correlationId this in to normal one like in IBM MQ.

Please be precise.
How do you check?
How do you print?
_________________
I like deadlines. I like to wave as they pass by.
ב''ה
Lex Orandi, Lex Credendi, Lex Vivendi. As we Worship, So we Believe, So we Live.
Back to top
View user's profile Send private message
RogerLacroix
PostPosted: Tue Jan 25, 2022 3:56 pm    Post subject: Re: How to read the correlation id Reply with quote

Jedi Knight

Joined: 15 May 2001
Posts: 3253
Location: London, ON Canada

This really isn't an MQ question rather a Java programming question. You appear to be new to Java.

There is a huge difference between a String and byte array. Also, there is no "toString" method for a byte array. And you should always seed the Random class when you instantiate it.
i.e.
Code:
Random R1 = new Random((new Date()).getTime());
byte [] corId = new byte[24];
R1.nextBytes(corId);

System.out.println("corId="+new String(corId));

It will convert the byte array to a String then print it out which will be like garbage and that is because we are dealing with a byte array and not a String.

If you want to compare what you are seeing in MQ Explorer, MQ Visual Edit or some other tool, then you need to be comparing byte array to byte array. A simple way to print out a byte array as a Hexadecimal string is to go grab my SimpleLogger and then do:
Code:
Random R1 = new Random((new Date()).getTime());
byte [] corId = new byte[24];
R1.nextBytes(corId);

SimpleLogger.infoDump("Correlation Id", corId);


Which will look like:
Code:
2022/01/25 18:46:09.800 INFO  (TestRandomBytes.<init>) Correlation Id -->>
2022/01/25 18:46:09.800 INFO  (TestRandomBytes.<init>) 000000: 53C578B0 D1B519E7 74AD0C03 8AA29686 74861DFA E9CD3F85                    S?x???.?t?..????t?.?????
2022/01/25 18:46:09.800 INFO  (TestRandomBytes.<init>) <<-----

Now you can compare HEX representation of Correlation Id with what you see in your MQ tool.

Regards,
Roger Lacroix
Capitalware Inc.
_________________
Capitalware: Transforming tomorrow into today.
Connected to MQ!
Twitter
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » How to read the correlation id
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.