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 » Java Custom Node: getting MsgID from MbElement

Post new topic  Reply to topic
 Java Custom Node: getting MsgID from MbElement « View previous topic :: View next topic » 
Author Message
Mirage
PostPosted: Thu Dec 09, 2004 7:41 am    Post subject: Java Custom Node: getting MsgID from MbElement Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 44
Location: IL

Hi,

I'm working on reading the MsgID from the input message in my custom node. I've queried the input message and got MsgID as a MbElement object.
Code:
MbElement msgIdElement = rootElement.getFirstElementByPath("/MQMD/MsgId");


I want to set this MsgId value into my MQ's MQMD java object for future reference and to compare the correlationId of another message.

Code:

MQMD reqMQMD = new MQMD();
reqMQMD.messageId = [b]--------------[/b]


Here is my problem, filling the dashes in the code. MQMD.messageId expects a byte array, where as MbElement.getValue() returns a Java Object.
How can I set the value of MsgId to MQMD's messageId ?

When I printout msgIdElement.getValue(), its printed in ASCII. Can I convert this object into a byte array and assign to MQMD.?


Thanks - RR.
Back to top
View user's profile Send private message
JLRowe
PostPosted: Thu Dec 09, 2004 7:49 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

Cast to byte array:
Code:

regMQMD.messageIf = (byte[])msgIdElement;
Back to top
View user's profile Send private message Send e-mail
Mirage
PostPosted: Thu Dec 09, 2004 7:58 am    Post subject: Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 44
Location: IL

Thanks Timna.

I dont know why I could not think of such a simple cast. Sometimes it just doesnt work.
Back to top
View user's profile Send private message
Mirage
PostPosted: Thu Dec 09, 2004 10:06 am    Post subject: Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 44
Location: IL

Hi ,

I changed the code to type cast to byte array and I'm storing the byte array in MQMD's messageId.

When I printout the values of these 2, there is a change in the value. I think the Message ID is getting changed when I type cast it. I'm not sure though.

Code:
MbElement msgIdElement = rootElement.getFirstElementByPath("/MQMD/MsgId");

logger.println("MSG ID's Value "+msgIdElement.getValue());

byte msgIdArray [] = (byte [])msgIdElement.getValue();

logger.println("Byte Array msgIdArray's value"+msgIdArray);

MQMD reqMQMD = new MQMD();

reqMQMD.messageId = msgIdArray;

logger.println("Length of MQMD "+msgIdArray.length);

logger.println("Message ID from MQMD after converted "+reqMQMD.messageId);


Here is the output for the print statements.
Quote:

MSG ID's Value [B@f73672d
Byte Array msgIdArray's value[B@f62672d
Length of MQMD 24
Message ID from MQMD after converted [B@f62672d


Am I doing anything wrong in copying the values ? Please suggest.

Thanks - RR.
Back to top
View user's profile Send private message
JLRowe
PostPosted: Thu Dec 09, 2004 10:25 am    Post subject: Reply with quote

Yatiri

Joined: 25 May 2002
Posts: 664
Location: South East London

The println's are giving you the address of the Object, not it's actual contents. String accepts a byte array as a constructor, and will convert the byte[] to a String.

Do this:

Code:

System.out.println(new String(msgIdArray));
Back to top
View user's profile Send private message Send e-mail
Mirage
PostPosted: Thu Dec 09, 2004 10:41 am    Post subject: Reply with quote

Apprentice

Joined: 30 Nov 2004
Posts: 44
Location: IL

I changed it to
Code:
new String(msgIdArray);

and the print statement was
Quote:
AMQ MSGBRK_QM ?¸A 


Which is somewhat similar to the view from RFHUtil but not same.

Instead of comparing with these special characters, is there a way to convert this 24 byte array to the hex format. That way I can easily compare them with RFHUtil.

Does MQMD.messageID also point to the same memory location ?. In the print statements both are looking same.
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 » Java Custom Node: getting MsgID from MbElement
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.