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 » Setting Message ID in Java

Post new topic  Reply to topic
 Setting Message ID in Java « View previous topic :: View next topic » 
Author Message
MQNewBaby
PostPosted: Mon Oct 19, 2009 5:18 pm    Post subject: Correlation ID Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Mon Oct 19, 2009 5:28 pm    Post subject: Reply with quote

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
View user's profile Send private message
fjb_saper
PostPosted: Mon Oct 19, 2009 9:59 pm    Post subject: Reply with quote

Grand High Poobah

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


_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
meetgaurav
PostPosted: Wed Oct 21, 2009 1:31 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Wed Oct 21, 2009 4:04 am    Post subject: Reply with quote

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
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 » Setting Message ID in Java
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.