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 » more getJMSCorrelationID question

Post new topic  Reply to topic
 more getJMSCorrelationID question « View previous topic :: View next topic » 
Author Message
rsinha
PostPosted: Mon Jan 10, 2005 10:58 am    Post subject: more getJMSCorrelationID question Reply with quote

Apprentice

Joined: 29 Aug 2003
Posts: 42

Hi,
I did search this forum for the related problem, but wasn't able to get a clear understanding of how to convert from hex correlId to a proper ascii char. My send application is using setJMSCorrelationID("0000"), the receive application, when does String correlID = getJMSCorrelationID(), displays following value -

ID:303030300000000000000000000000000000000000000000

Tried using following code to first convert the correlID to bytes and then toHexString()

// convert CorrelId character string into bytes
byte [] bytes = testString.getBytes();
StringBuffer sb = new StringBuffer();
for(int i = 0; i < bytes.length ; i++)
{
sb.append(Integer.toHexString(bytes[i]));
}
int correlationIDLength = 48;
int zerosToFill = correlationIDLength - sb.length();
for(int i = 0; i < zerosToFill; i++ )
{
sb.append("0");
}

This displays -
49443a333033303330333030303030303030303030303030303030303030303030303030303030303030303030303030303030

Which translates to -
hex char
---------------
49 I
44 D
3a :
33 3
30 0
33 3
30 0

As you can see, it still is in hex, in addition, it changed from orig value of "0000" to "30303030"

Can anyone explain how I can get the exact value of "0000" in correlID when I retrieve the message and its MQMD header?

Thanx
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jan 10, 2005 11:08 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Correlation IDs are not "proper ascii chars".

They are fields that contain binary characters that may or may not map to useable, printable ascii characters.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
rsinha
PostPosted: Mon Jan 10, 2005 11:21 am    Post subject: Reply with quote

Apprentice

Joined: 29 Aug 2003
Posts: 42

so what does that mean? when I don't use JMS to retrieve the correlID, when I simply use amqsbcg qname, the browser program that came with MQ, it clearly shows me the CorrelID field at MQMD header, containing the exact hex value for "0000".

StrucId : 'MD ' Version : 2
Report : 0 MsgType : 8
Expiry : -1 Feedback : 0
Encoding : 273 CodedCharSetId : 1208
Format : 'MQSTR '
Priority : 4 Persistence : 1
MsgId : X'414D512045324F50454E2E4445562E519F57DC4101030020'
CorrelId : X'303030300000000000000000000000000000000000000000'

So why can't JMS interpret it correctly?
Thanx
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Jan 10, 2005 11:47 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

What are you actually trying to do with your correlation ID?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jan 10, 2005 11:50 am    Post subject: Reply with quote

Grand High Poobah

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

Read the manual
When the MsgID/CorrelID is in the provider's format it is rendered as:
"ID:" + hex representation of byte array.

Enjoy


Last edited by fjb_saper on Mon Jan 10, 2005 11:52 am; edited 1 time in total
Back to top
View user's profile Send private message Send e-mail
rsinha
PostPosted: Mon Jan 10, 2005 11:52 am    Post subject: Reply with quote

Apprentice

Joined: 29 Aug 2003
Posts: 42

Our Trading Partner is sending some identifier in this field, which our application is supposed to retrieve and take some action based on the identifier (value) they've sent in correlID field.

Thanx
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jan 10, 2005 11:56 am    Post subject: Reply with quote

Grand High Poobah

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

You need to request the byte value of the partner's identifier from the partner.
If there is a platform change (as400 -> unix or pc) etc... the bytes are not converted from one CCSID to the other. (EBCDIC to ASCII).
You need to treat the information as bytes!

Enjoy
Back to top
View user's profile Send private message Send e-mail
rsinha
PostPosted: Mon Jan 10, 2005 12:21 pm    Post subject: Reply with quote

Apprentice

Joined: 29 Aug 2003
Posts: 42

Yes, When I do getJMSCorrelationIDAsBytes(), that does give me the correct value of "0000", how ever, the partner is using some other charset, that we have no knowledge of. We use following code -

String correlId = new String(message.getJMSCorrelationIDAsBytes());

As you can seem, with String coversion, this code is assuming that the charset used in corelID is the default machine charset, which in our case is utf-8. But I know for sure that partner is using some othe charset, because using the above code when we check the correlId.length(), it give us 0. I think thats happening due to wrong charset conversion.
Thats why I wanted to use getJMSCorrelationID(), hoping that JMS would be smart enough to do the charset conversion from whatever the partner is sending, to utf-8. But in that case we are facing a different hurdle, the string is coming as a hex string, which is no good to us.
Thanx
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Jan 10, 2005 12:55 pm    Post subject: Reply with quote

Grand High Poobah

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

As stated before:
You CANNOT treat the msgID/correlationID fields as String fields.
They are byte arrays and will not be converted when the CCSID changes.
You need to request the byte[] value of the field as the sender put it in and compare to the same byte[].

Enjoy
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » more getJMSCorrelationID question
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.