|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to read the correlation id |
« View previous topic :: View next topic » |
Author |
Message
|
pras120687 |
Posted: Tue Jan 25, 2022 7:44 am Post subject: How to read the correlation id |
|
|
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 |
|
 |
bruce2359 |
Posted: Tue Jan 25, 2022 10:56 am Post subject: Re: How to read the correlation id |
|
|
 Poobah
Joined: 05 Jan 2008 Posts: 9469 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 |
|
 |
RogerLacroix |
Posted: Tue Jan 25, 2022 3:56 pm Post subject: Re: How to read the correlation id |
|
|
 Jedi Knight
Joined: 15 May 2001 Posts: 3264 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 |
|
 |
|
|
 |
|
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
|
|
|
|