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 » Writing to a file

Post new topic  Reply to topic Goto page 1, 2  Next
 Writing to a file « View previous topic :: View next topic » 
Author Message
bijesh
PostPosted: Sun Mar 11, 2007 8:42 pm    Post subject: Writing to a file Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

Hi,

I've a flow , MQInput -> Java compute node.

MQInput node uses an MRM parser to read the input message from a queue. Java compute node writes the message to a file. When I do this, I'm getting an exception as below.

<com.ibm.broker.plugin.MbParserException class:JNI method:CpContext::loadWorker
source:BIPv600 key:5136 >
at com.ibm.broker.plugin.MbElement._toBitstream(Native Method)
at com.ibm.broker.plugin.MbElement.toBitstream(MbElement.java:2221)
at com.tgt.wbimb.enterprise.amzgiftregistry.AMZGR_FILE_WRITE_MF_JavaComp
ute.evaluate(AMZGR_FILE_WRITE_MF_JavaCompute.java:45)
at com.ibm.broker.javacompute.MbRuntimeJavaComputeNode.evaluate(MbRuntim
eJavaComputeNode.java:105)
at com.ibm.broker.plugin.MbNode.evaluate(MbNode.java:1222)


Instead of MRM parser, If I'm sending an XML message and parse it using an XMLNSC parser the data gets written to the file.

Any thoughts to share on this?
Back to top
View user's profile Send private message
bijesh
PostPosted: Sun Mar 11, 2007 8:52 pm    Post subject: Re: Writing to a file Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

The code being used in the Java compute node follows..

Code:
MbElement mbElement=inMessage.getRootElement();
         MbElement body=mbElement.getLastChild();
         System.out.println("the body of the message is "+body.getName());
         //MbElement body=mqmd.getNextSibling();
         b=body.toBitstream(null,null,null,0,1208,0);
                                   FileOutputStream fout=new FileOutputStream("c:\\Test2.txt",false);         
         fout.write(b);
         fout.close();
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Mar 12, 2007 2:20 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
toBitstream(null,null,null,


The docs say:
Quote:
public byte[] toBitstream(String messageType,
String messageSet,
String messageFormat,
int encoding,
int ccsid,
int options) throws MbException

You need to set the message set, message type and message format.
I do think the error message could be better, though.
Back to top
View user's profile Send private message
bijesh
PostPosted: Mon Mar 12, 2007 2:52 am    Post subject: Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

kimbert wrote:
Quote:
toBitstream(null,null,null,


The docs say:
Quote:
public byte[] toBitstream(String messageType,
String messageSet,
String messageFormat,
int encoding,
int ccsid,
int options) throws MbException

You need to set the message set, message type and message format.
I do think the error message could be better, though.



When I provide the values for those arguments, the exception becomes this,

<com.ibm.broker.plugin.MbParserException class:JNI method:MtiImbRMErrorMap::chec
kRC source:BIPv600 key:5304 >
at com.ibm.broker.plugin.MbElement._toBitstream(Native Method)
at com.ibm.broker.plugin.MbElement.toBitstream(MbElement.java:2221)
at com.tgt.wbimb.enterprise.amzgiftregistry.AMZGR_FILE_WRITE_MF_JavaComp
ute.evaluate(AMZGR_FILE_WRITE_MF_JavaCompute.java:45)
at com.ibm.broker.javacompute.MbRuntimeJavaComputeNode.evaluate(MbRuntim
eJavaComputeNode.java:105)
at com.ibm.broker.plugin.MbNode.evaluate(MbNode.java:1222)
Back to top
View user's profile Send private message
kimbert
PostPosted: Mon Mar 12, 2007 4:46 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

You have set something incorrectly. Maybe the parameters are in the wrong order? ( toBitstream's parameters are Type, Set, Format which is not the usual order ).

I have a suggestion.
- insert a Compute node before your Java Compute node,
- use the ESQL function ASBITSTREAM to convert the message tree to a BLOB
- Change your java to expect a BLOB instead of a message tree.

If you do it this way, you will get better error messages. Once you get this working you may be able to switch back to using toBitstream.
Back to top
View user's profile Send private message
bijesh
PostPosted: Mon Mar 12, 2007 8:14 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

- Change your java to expect a BLOB instead of a message tree.

How can I make my java compute node to expect a BLOB instead of a message tree.?
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Mar 13, 2007 1:19 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Err, how about something like this:
Code:
MbElement mbElement=inMessage.getRootElement();

//Set MbElement to InputRoot.BLOB
MbElement body=mbElement.getLastChild();

//Set MbElement to InputRoot.BLOB.BLOB
MbElement BLOB =body.getLastChild();

//now get the value of BLOB and write it to the file
...
Back to top
View user's profile Send private message
bijesh
PostPosted: Tue Mar 13, 2007 2:54 am    Post subject: Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

kimbert wrote:
Err, how about something like this:
Code:
MbElement mbElement=inMessage.getRootElement();

//Set MbElement to InputRoot.BLOB
MbElement body=mbElement.getLastChild();

//Set MbElement to InputRoot.BLOB.BLOB
MbElement BLOB =body.getLastChild();

//now get the value of BLOB and write it to the file
...


Not much success..
the 'body' itself gives me 'MRM' as the last child.
again getting last child gives me the last element in the MRM.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Mar 13, 2007 3:23 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

OK - sorry for confusing you. I should have told you do this:

In the Compute node which you inserted:
- use ASBITSTREAM to convert your MRM tree to a BLOB.
- save that BLOB in the environment tree.

In the Java Compute node
- access the environment tree and save the BLOB to your file.
Back to top
View user's profile Send private message
bijesh
PostPosted: Tue Mar 13, 2007 7:59 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

kimbert wrote:
OK - sorry for confusing you. I should have told you do this:

In the Compute node which you inserted:
- use ASBITSTREAM to convert your MRM tree to a BLOB.
- save that BLOB in the environment tree.

In the Java Compute node
- access the environment tree and save the BLOB to your file.


thanks a lot for your suggestions.
tried it, but results in the same exception. Even if the data is in the environment as a blob , I need to use the toBitStream function to convert it into bytes, right? Then only i'l b able to write into a file.
Back to top
View user's profile Send private message
bijesh
PostPosted: Tue Mar 13, 2007 8:01 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

One more thing is,
instead of an MRM document, If the input is an XML document it is getting written to the file as it is. No exceptions are thrown at this point.
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Wed Mar 14, 2007 4:28 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

You won't need to use toBitstream() on a BLOB type. MbElement.getValue should return a bytes[] if the element is a BLOB.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
bijesh
PostPosted: Wed Mar 14, 2007 9:36 pm    Post subject: Reply with quote

Acolyte

Joined: 30 Jan 2007
Posts: 66

jefflowrey wrote:
You won't need to use toBitstream() on a BLOB type. MbElement.getValue should return a bytes[] if the element is a BLOB.


Thanks Jefflowrey..
I 'm getting some success out of this..
Thanks to Kimbert too...
Back to top
View user's profile Send private message
team
PostPosted: Thu Oct 04, 2007 5:19 am    Post subject: Reply with quote

Centurion

Joined: 03 Nov 2006
Posts: 108

Hi,

I do a very similar thing:

MbMessage inMessage = contact admin.getMessage();
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,outMessage);

String filename = "c:\temp.txt";
File outfile = new File(filename);
FileOutputStream fos = new FileOutputStream(outfile);

//fos.write(outMessage.getRootElement().getLastChild().getName().getBytes());

fos.write((byte[])outMessage.getRootElement().getLastChild().getValue());

However the file is empty.
If outMessage.getRootElement().getLastChild().getName().getBytes() , this gives me the result as BLOB. Would you know where I am going wrong?

Rgds
Back to top
View user's profile Send private message Yahoo Messenger
fjb_saper
PostPosted: Thu Oct 04, 2007 2:35 pm    Post subject: Reply with quote

Grand High Poobah

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

Wouldn't the bytes be in the BLOB.BLOB?

So :
outMessage.getRootElement().getLastChild().getLastChild().getValue();

_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Writing to a file
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.