Author |
Message
|
SandiSan |
Posted: Fri Dec 08, 2006 7:23 am Post subject: Converting String To BLOB and ViceVersa In JavaCompute Node. |
|
|
 Acolyte
Joined: 01 Apr 2006 Posts: 57 Location: Pune/India
|
Hi All,
I want to convert MQMD->MsgId that is comming as BLOB to String and also do the reverse conversion in JavaCompute.This is what i have tried.
1. Converting MsgId in BLOB to String
// Getting MsgId from MQMD
MbElement msgId = outMessage.getRootElement().getFirstChild().getNextSibling().getFirstElementByPath("MsgId");
// Converting MsgId to String
String sMsgId = msgId.getValue().toString();
But the String value what i am getting is : [B@70089286.
2. Converting String Id in BLOB.
Here i want to achieve the flollowing in JavaCompute InputRoot"."MQMD"."MsgId" = CAST('MYOWNMSGID' AS BLOB); that we can do in Compute Node using ESQL . I tried
// Getting MsgId from Input Messge
MbElement msgidval= inMsg.getFirstElementByPath("MsgId");
// Getting BLOB value to MQMD/MsgId
mbMqmdMsgId.setValue(msgidval.getValue().getBytes());
Regards
SandiSan |
|
Back to top |
|
 |
kevinf2349 |
Posted: Fri Dec 08, 2006 7:32 am Post subject: |
|
|
 Grand Master
Joined: 28 Feb 2003 Posts: 1311 Location: USA
|
Search this site with BLOB and MSGID as search words. I think this was answered some time ago. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Dec 08, 2006 7:41 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Also, you don't want to do this.
You should change the sending application so that it doesn't try and use a transport header that is defined to only hold byte values, to store business information.
Do not use MsgId to hold strings. Do not use MsgId to hold "information". _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
SandiSan |
Posted: Fri Dec 08, 2006 9:53 am Post subject: |
|
|
 Acolyte
Joined: 01 Apr 2006 Posts: 57 Location: Pune/India
|
@kevinf2349
We can easily convert STRING-BLOB in ComputeNode. But i want to do it in Java Compute Node.
@jefflowrey
I guess i may have confused you.Actually my scenario is i have MsgId stored as String and i want to reterive that value and set it to MQMD-->MsgId. Since MQMD-->MsgId Datatype is BLOB i am stuck with converting String-To-BLOB In JavaCompute Node
Regards
Sandisan. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Dec 08, 2006 10:37 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
getValue will return a byte[] if the element is a BLOB element.
getValue will return a String if the element is a CHARACTER element.
setValue will accept a byte[] or a String. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
billybong |
Posted: Sun Dec 10, 2006 1:54 pm Post subject: |
|
|
 Disciple
Joined: 22 Jul 2005 Posts: 150 Location: Stockholm, Sweden
|
What you're probably looking for is to represent byte data in HEX format, which means as strings. Google for "byte to string HEX conversion" and you'll probably find some piece of code that does just that. _________________ IBM Certified Solution Developer - WebSphere Message Broker V6.1
IBM Certified Solution Developer - WebSphere Integration Developer V6.0
IBM Certified System Administrator - WebSphere MQ V6.0
IBM Certified Solution Developer - WebSphere DataPower |
|
Back to top |
|
 |
|