|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Read blob message using Java Compute node throwing exception |
« View previous topic :: View next topic » |
Author |
Message
|
anilmekala |
Posted: Tue Feb 18, 2014 1:30 am Post subject: Read blob message using Java Compute node throwing exception |
|
|
Acolyte
Joined: 19 Oct 2012 Posts: 63
|
Hi All,
I am getting exception while reading blob message in JCN.
I have create flow MQ INput --> JCN --> MQ out . I have set Message domain as blob when am trying to read the blog message am getting null pointer exception. I am pasting my code as below
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");
MbMessage inMessage = contact admin.getMessage();
MbElement inRoot = inMessage.getRootElement();
MbElement blob = inRoot.getLastChild();
// create new message
MbMessage outMessage = new MbMessage(inMessage);
MbElement outputRoot = outMessage.getRootElement();
MbElement outputBody = outputRoot.createElementAsLastChild(MbBLOB.PARSER_NAME);
byte[] mybytes=(byte[]) blob.getValue();
String MessageBodyString = new String(mybytes);-- getting null pointer exception.
MessageBodyString = MessageBodyString + " adding string text to mesage body";
//text.concat("Welcome");
MbElement blobData = outputBody.createElementAsFirstChild(MbElement.TYPE_NAME_VALUE, "BLOB", MessageBodyString.getBytes());
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,
outMessage);
Please help me to resolve the issue.
Thanks in Advance.
Anil. |
|
Back to top |
|
 |
Gralgrathor |
Posted: Tue Feb 18, 2014 1:56 am Post subject: |
|
|
Master
Joined: 23 Jul 2009 Posts: 297
|
The ESQL reference to your BLOB would be:
Code: |
InputRoot.BLOB.BLOB |
To get at the contents of the blob, you'd therefore have to
Code: |
MbElement outerblob = inRoot.getLastChild();
MbElement blob = outerblob.getLastChild(); <--
byte[] mybytes=(byte[]) blob.getValue(); |
|
|
Back to top |
|
 |
anilmekala |
Posted: Tue Feb 18, 2014 3:03 am Post subject: |
|
|
Acolyte
Joined: 19 Oct 2012 Posts: 63
|
Hi ,
Thank you so much it resolved my issue.
Regards,
Anil. |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|