|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Setting Message ID in Java |
« View previous topic :: View next topic » |
Author |
Message
|
MQNewBaby |
Posted: Mon Oct 19, 2009 5:18 pm Post subject: Correlation ID |
|
|
Newbie
Joined: 19 Oct 2009 Posts: 1
|
Hi All,
I have string let say String str = "4023COSTO" and i want to set this as Message ID, how do i do that? how to convert this string to hexBinary.
My Problem
I have two application one in WESB in which I can set only hextBinary to Message ID and another application is setting response CorrelationID in Java like this
MQMessage requestMessage = new MQMessage();
String tempCorrelationId = new String("4023COST");
requestMessage.correlationId = tempCorrelationId.getBytes();
but the WESB is not picking up the response. Do i need do any conversion in Java Code? Please help me. |
|
Back to top |
|
 |
Vitor |
Posted: Mon Oct 19, 2009 5:28 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
I know very little about Java, but 3 things occur to me:
- the correlation id should be set to the message id of the request rather than some string as best design practice
- you can't assign a string to the id fields because they're binary not string as you say, so they may not match on machines with different code pages (and I've no idea how you do that in Java)
- even if the reponse is for some reason that string, and the string value matches, the reply won't be found because that string is too short to be an id.
Go back, read the documentation and rethink what you're doing. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Oct 19, 2009 9:59 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
meetgaurav |
Posted: Wed Oct 21, 2009 1:31 am Post subject: |
|
|
Voyager
Joined: 08 Sep 2008 Posts: 94
|
New Baby try this conversion logic
This may help you out.
[code] public static byte[] toByteArray(String hexStr)
{
byte msgId[] = new byte[hexStr.length()/2];
for(int i=0; i<(hexStr.length()/2); i++)
{
byte firstNibble = Byte.parseByte(hexStr.substring(2*i,2*i+1),16);
byte secondNibble = Byte.parseByte(hexStr.substring(2*i+1,2*i+2),16);
int finalByte = (secondNibble) | (firstNibble << 4 );
msgId[i] = (byte) finalByte;
}
return msgId;
}
[/code] |
|
Back to top |
|
 |
Vitor |
Posted: Wed Oct 21, 2009 4:04 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
meetgaurav wrote: |
New Baby try this conversion logic
This may help you out.
|
Or may cause further problems - I refer to previous discussions on the perils of creating your own message id in this thread and others.
Though I'm sure it's a very nice piece of Java for converting a string!  _________________ Honesty is the best policy.
Insanity is the best defence. |
|
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
|
|
|
|