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 » Copy MQMD.MsgId to MQMD.CorrelId Java Compute Node Issue

Post new topic  Reply to topic
 Copy MQMD.MsgId to MQMD.CorrelId Java Compute Node Issue « View previous topic :: View next topic » 
Author Message
satya2481
PostPosted: Thu Dec 16, 2010 2:51 am    Post subject: Copy MQMD.MsgId to MQMD.CorrelId Java Compute Node Issue Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Hi All,
I am using WMB V6.1 Toolkit and Runtime components.

I am facing an issue with copying MQMD.MsgId to element to MQMD.CorrelId in JCN node. My requirement is as below.

Flow 1
1. Get the message from the Queue, read as BLOB message
2. Convert the message from BLOB domain to XMLNS domain
3. Copy MQMD.MsgId and store it in the newly constructed XMLNS Message, create an element called "MessageId" and store some where in the message (Please note that not in any header)
4. Put the message to output queue

Flow 2
1. Get the message from the Queue sent from Flow 1
2. Get the "<MessageId>" field value from the message
3. Copy the MessageId to MQMD.CorrelId
4. Put the message to output queue

My code looks like below...

Flow1. Step 3
Code:
MbElement inMsgId = inRoot.getFirstElementByPath("/MQMD/MsgId");
byte[] mByte = (byte[]) (inMsgId.getValue()) ;
MbElement outMessageId = inParsedMessage.getFirstChild().getFirstChild().getFirstChild().createElementAsFirstChild(MbXMLNS.ELEMENT, "MessageId", mByte );


Flow2 Step 3.
Code:
MbElement messageId = outRoot.getFirstElementByPath("/XMLNS/MsgRoot/Name/FName/MessageId");
MbElement outCorrelId = outRoot.getFirstElementByPath("/MQMD/CorrelId");
outCorrelId.setValue((byte[])(messageId.getValue()));


I am getting "ClassCastException" in the Flow2.

Please let me know how to resolve this issue...

Please note that I have to pass the MsgId as part of the message and not as part of the MQMD or MQRFH2 header.

Regards
Satya
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Thu Dec 16, 2010 4:01 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Well, it's not going to work to store a message ID as a plain value into a string value in an XML document, as the message ID will very easily contain non-printable and illegal XML characters, and may in fact include lovely things like >, <, or /.

Secondly, you should be using XMLNSC, not XMLNS.

Thirdly, if you do a cast of the value as you did, you will likely end up with a significantly longer field than 24 bytes, because the original 24 bytes you put in have now been treated as unicode characters.

You need to do something to ensure that you can preserve actual byte values across this transformation, which you have not done as yet. Some options include turning the bytes into two character hex representations, or using a base64 encoding.
Back to top
View user's profile Send private message
satya2481
PostPosted: Thu Dec 16, 2010 11:30 pm    Post subject: Reply with quote

Disciple

Joined: 26 Apr 2007
Posts: 170
Location: Bengaluru

Hi,

I have used java "Stack" to Push and Pop Message ID. Problem is resolved. However I need to tune my code

Regards
Satya
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 » WebSphere Message Broker (ACE) Support » Copy MQMD.MsgId to MQMD.CorrelId Java Compute Node Issue
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.