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 » Correlation ID is changed

Post new topic  Reply to topic
 Correlation ID is changed « View previous topic :: View next topic » 
Author Message
Nikky72
PostPosted: Wed Oct 08, 2008 2:22 am    Post subject: Correlation ID is changed Reply with quote

Newbie

Joined: 08 Oct 2008
Posts: 3

Hello,

I'm new user of the java API and I have a problem that I can not resolved. I try to explain what my problem is.
I have developped a java application that transfer messages between 2 Queues (you can configure the Queue you want to connect to, and the application can connect MQ or Oracle Advance Queue AQ).
I have to set a correlation ID. It is the HEX-String: 00000000000000000000000000000000F9F0F0F9F2C2D600.
With a java Methode HexToByte(String hex) I transform this hex-string to a byte array which I set as correlation ID (using MQMessage.correlationID). The problem is that after transfering the message (using MQMessage.write( byte []) ) the correlation ID is changed to:
000000000000000000000000000000090092B002020D600. As you can see the fragment "F9F0F0F9F2C2" is chanded to "90092B002020". If you try to convert the string "90092B" in HEX you will get "F9F0F0F9F2C2".
Could somebody explain me why this conversion occurs!! Please help me. I'm despaired

PS. My java fonction to convert HexTOByte:
private byte[] hexToByte( String hexString )
{
int arrayCount = 0, position = 0;
hexString = hexString.toUpperCase();
byte[] bytes = new byte[ hexString.length() / 2 ];

while( arrayCount < bytes.length )
{
bytes[ arrayCount ] = (byte)Integer.parseInt(
hexString.substring( position, position+2 ), 16 );

// Increment my counters
position += 2;
arrayCount++;
}

return bytes;
}
Back to top
View user's profile Send private message
atheek
PostPosted: Wed Oct 08, 2008 2:47 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

Nikky72 wrote:
The problem is that after transfering the message (using MQMessage.write( byte []) ) the correlation ID is changed to:
000000000000000000000000000000090092B002020D600


How are you checking the correlationID in the message after you set it ie. how do you know it actually changed.

Did you check using amqsbcg? Or are you using code to convert the byte array to hex string. I think the problem is here...

The below piece of code can correctly convert a byte array to a hex string:

Code:
static char[] hexChar = {
           '0' , '1' , '2' , '3' ,
           '4' , '5' , '6' , '7' ,
           '8' , '9' , 'A' , 'B' ,
           'C' , 'D' , 'E' , 'F'
   };
 
   public static String toHexString ( byte[] b ) {
       StringBuffer sb = new StringBuffer( b.length * 2 );
       for ( int i=0; i<b.length; i++ ) {
           // look up high nibble char
           sb.append( hexChar [( b[i] & 0xf0 ) >>> 4] ); // fill left with zero bits
 
           // look up low nibble char
           sb.append( hexChar [b[i] & 0x0f] );
       }
       return sb.toString();
   }
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Oct 08, 2008 3:02 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

atheek gave you the right to hex string.
to convert back to a byte array you are doing the wrong thing.
DO NOT use Integer.parseInt(). Look into Integer.decode()

But if you need it as a byte[], you can retrieve it as a byte[] from MQ or JMS... (message.getCorrelIdAsBytes()?)

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Nikky72
PostPosted: Wed Oct 08, 2008 3:21 am    Post subject: Reply with quote

Newbie

Joined: 08 Oct 2008
Posts: 3

Hello

Thank you for then replíes.
To atheek: I know that the correlation id has been changed because the Application that receive my message triggers an exception because of my correlation id. In the trace file of this application that receive my message you can see that the correlation id contains "90092B002020" instead of "F9F0F0F9F2C2". When I use the code you give to me to convert my correlation id back to HEX (making toHexString(MQMessage.correlationId) ) before doing MQMessage.write() and MQQueue.put() the correlation ID is still correct. When the message arrives to it's destination the trace file show another correlation ID.

To fjb_saper: Thank you for the suggestion. I've tried to use the Integer.decode() but my application crashe with: Exception in thread "Thread-1" java.lang.NumberFormatException: For input string: "C9"

Thank you for helping.
Back to top
View user's profile Send private message
atheek
PostPosted: Wed Oct 08, 2008 3:28 am    Post subject: Reply with quote

Partisan

Joined: 01 Jun 2006
Posts: 327
Location: Sydney

Nikky72 wrote:
When the message arrives to it's destination the trace file show another correlation ID.


Could it be that other application is written wrongly to interpret the correlation ID.

Ask them to stop consumption from the queue. Trap the messages in the queue and inspect the message header using amqsbcg or rfhutil(c) for the Correlation ID . If you see it that the correlation id is same in the message in the queue as what you have set it, then its not your problem anymore. Ask the receiving application to fix their code.[/quote]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Wed Oct 08, 2008 3:30 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20756
Location: LI,NY

Nikky72 wrote:
Hello

Thank you for then replíes.

To fjb_saper: Thank you for the suggestion. I've tried to use the Integer.decode() but my application crashe with: Exception in thread "Thread-1" java.lang.NumberFormatException: For input string: "C9"

Thank you for helping.


So you tried blindly without reading up on decode.
You would / should have noticed that your input string is missing a "0x" in front of it. Don't remember if it will be case sensitive though ...
It might understand "0xc9" and not "0xC9"... so read up. It's all explained in the API description somewhere.

Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Nikky72
PostPosted: Wed Oct 08, 2008 4:21 am    Post subject: Reply with quote

Newbie

Joined: 08 Oct 2008
Posts: 3

Hello once more

Thank you for all the tips!!! The problem has been solved. Atheek you were right I asked the receiving application to check their code once more and they find out a bug!!
Now everything is working fine and my correlation ID reachs it's destination without any changes!!!

Many Thanks you for helping and bye!!!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Correlation ID is 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.