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 » WebSphere Message Broker (ACE) Support » Issue with setting correlId in jcn

Post new topic  Reply to topic
 Issue with setting correlId in jcn « View previous topic :: View next topic » 
Author Message
jr_martin
PostPosted: Fri Nov 21, 2008 11:22 am    Post subject: Issue with setting correlId in jcn Reply with quote

Apprentice

Joined: 24 Aug 2005
Posts: 36
Location: NY

Hi,
I am trying to set the correlId in JCN with the following code. Can someone confirm if this is the correct code? Debugger is just hanging at out.propagate statement.

WMB 6.0.3 runtime@solaris

MbMessage message = incomingAssembly.getMessage();
MbMessage NewMessage = new MbMessage();
copyMessageHeaders(message, NewMessage);
MbElement outRoot = NewMessage.getRootElement();
MbElement mqmd = outRoot.createElementAsFirstChild("MQHMD");
mqmd.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"CorrelId","X'445F374E4C4F4144574F524B554E49540000000000000000'");
out.propagate(new MbMessageAssembly(incomingAssembly, NewMessage));

Thanks.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 21, 2008 3:25 pm    Post subject: Re: Issue with setting correlId in jcn Reply with quote

Grand High Poobah

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

jr_martin wrote:
Hi,
I am trying to set the correlId in JCN with the following code. Can someone confirm if this is the correct code? Debugger is just hanging at out.propagate statement.

WMB 6.0.3 runtime@solaris

MbMessage message = incomingAssembly.getMessage();
MbMessage NewMessage = new MbMessage();
copyMessageHeaders(message, NewMessage);
MbElement outRoot = NewMessage.getRootElement();
MbElement mqmd = outRoot.createElementAsFirstChild("MQHMD");
mqmd.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"CorrelId","X'445F374E4C4F4144574F524B554E49540000000000000000'");
out.propagate(new MbMessageAssembly(incomingAssembly, NewMessage));

Thanks.


So what part of this code do you not understand?

  • you copy the headers: Properties, MQMD, RFH
    but yet you feel the need to CREATE the MQMD again, and as FIRST CHILD? That's the Properties.... The underlying assumption I made was that MQ is your provider and you are not using a JMS node... or if you are you are past the JMS to MQ translation node.
  • So you have created the CorrelId as element and you do assign it a value. Never mind any other fields that you should probably fill out as a minimum on the MQMD...
  • Wouldn't it just have been plain easier, once you copied the headers to navigate to the correlid field and to set it?
  • Last but not least the JMSCorrelationId on the RFH header may use more than 24 bytes. If it does the MQMD-CorrelationId will truncate that value at 24 bytes. So you might need to set both fields ...


Enjoy
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
rekarm01
PostPosted: Fri Nov 21, 2008 8:34 pm    Post subject: Re: Issue with setting correlId in jcn Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 1415

jr_martin wrote:
Code:
mqmd.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE,"CorrelId","X'445F374E4C4F4144574F524B554E49540000000000000000'");

Since MQMD.CorrelId is a BLOB, not a CHARACTER, don't you need to assign a byte[] to it, rather than a String?
Back to top
View user's profile Send private message
jr_martin
PostPosted: Mon Nov 24, 2008 6:33 am    Post subject: Reply with quote

Apprentice

Joined: 24 Aug 2005
Posts: 36
Location: NY

Thanks for the suggestions.

As you said, Copying header, setting the value was easy. Code stated below worked ok for me.

However, the string (ABCD...) must be of 24 characters. Otherwise, I get the exception-"length must be correct".So I ended up in putting spaces to make it 24 characters for smaller strings. Is there any other way to bypass putting spaces?


Code:
MbMessage InMessage = incomingAssembly.getMessage();
MbMessage OutMessage = new MbMessage(InMessage);
MbElement outRoot = OutMessage.getRootElement();

MbElement CorrelIdElement = outRoot.getFirstElementByPath("/MQMD/CorrelId");
Object cid = CorrelIdElement.getValue();


String cid_str = "ABCDEFGHIJKLMNOPQRSTUVWX";
CorrelIdElement.setValue(cid_str.getBytes());

out.propagate(new MbMessageAssembly(incomingAssembly, OutMessage));[/quote]
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Nov 24, 2008 3:39 pm    Post subject: Reply with quote

Grand High Poobah

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

jr_martin wrote:
Thanks for the suggestions.

As you said, Copying header, setting the value was easy. Code stated below worked ok for me.

However, the string (ABCD...) must be of 24 characters. Otherwise, I get the exception-"length must be correct".So I ended up in putting spaces to make it 24 characters for smaller strings. Is there any other way to bypass putting spaces?


Code:
MbMessage InMessage = incomingAssembly.getMessage();
MbMessage OutMessage = new MbMessage(InMessage);
MbElement outRoot = OutMessage.getRootElement();

MbElement CorrelIdElement = outRoot.getFirstElementByPath("/MQMD/CorrelId");
Object cid = CorrelIdElement.getValue();


String cid_str = "ABCDEFGHIJKLMNOPQRSTUVWX";
CorrelIdElement.setValue(cid_str.getBytes());

out.propagate(new MbMessageAssembly(incomingAssembly, OutMessage));
[/quote]

Typically the correlId is a byte[] and not a String.
JMSGetCorrelationId returns a String as in Hex representation of the byte[]

So once you have the byte[] by String.getBytes() you can fill up to byte[24] by initializing the missing bytes with 0x00 (this is what JMS does when being passed a string of less than 24 char. When passing the hex representation to JMS in String form you should always have 51chars The extra 3 being "ID:") :enjoy:
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
jr_martin
PostPosted: Tue Nov 25, 2008 6:58 am    Post subject: Reply with quote

Apprentice

Joined: 24 Aug 2005
Posts: 36
Location: NY

Some wise guy already wrote the code:

String cid_hex_str = "444F574E4C4F4144574F524B554E49540000000000000000";
byte[] cid_bytes = new byte[24];
for (int i = 0; i < 24; i++)
{
cid_bytes[i] = (byte) Integer.parseInt(cid_hex_str.substring(i * 2, i * 2 + 2), 16);
}

Reference:http://integration.chapmanhaus.com/wiki/MQ/Java-MsgID-CorrelId
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 » WebSphere Message Broker (ACE) Support » Issue with setting correlId in jcn
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.