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 » JavaCompute Node detach()

Post new topic  Reply to topic
 JavaCompute Node detach() « View previous topic :: View next topic » 
Author Message
cmmatei
PostPosted: Tue Oct 10, 2006 4:43 am    Post subject: JavaCompute Node detach() Reply with quote

Apprentice

Joined: 06 Feb 2006
Posts: 26
Location: PARIS/NEW YORK

Hello,

I would like to copy the xml data of a message into a file.

I use a JavaCompute Node as it follows :

evaluate(MbMessageAssembly assembly) throws MbException {


..............

MbMessageAssembly outAssembly = new MbMessageAssembly(assembly, assembly.getMessage());
MbElement mqmdHeader = outAssembly.getMessage().getRootElement().getFirstChild().getNextSibling();
mqmdHeader.detach();
MbMessage msg = outAssembly.getMessage();
byte[] bitstream = msg.getBuffer();


//write bitestream to a file
...........


The problem is that the detach() method fails.

I would like to know why detach() throws an exception and which is the good way to get only the xml data from the message.

Thank you,
Cornel
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Oct 10, 2006 4:51 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

How does it fail? What's the exception?
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
kimbert
PostPosted: Tue Oct 10, 2006 5:07 am    Post subject: Reply with quote

Jedi Council

Joined: 29 Jul 2003
Posts: 5542
Location: Southampton

Quote:
which is the good way to get only the xml data from the message
No idea why detach() fails. But why would ASBITSTREAM not do what you need? ( search this forum if you need an example - there must be dozens of posts about this ).
Back to top
View user's profile Send private message
cmmatei
PostPosted: Tue Oct 10, 2006 6:06 am    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2006
Posts: 26
Location: PARIS/NEW YORK

Seems that can't read the content of the message?

'com.ibm.broker.plugin.MbReadOnlyMessageException'

(0x03000000):Catalog = 'BIPv600'
(0x03000000):Severity = 3
(0x03000000):Number = 4395
(0x03000000):Text = 'Unhandled exception in plugin method'
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'com.ibm.broker.plugin.MbReadOnlyMessageException'
)
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'com.ibm.broker.plugin.MbElement'
)
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'detach'
)
(0x01000000):Insert = (
(0x03000000):Type = 5
(0x03000000):Text = 'MbElement.java'
)
Back to top
View user's profile Send private message
cmmatei
PostPosted: Tue Oct 10, 2006 8:00 am    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2006
Posts: 26
Location: PARIS/NEW YORK

Please find here the JavaComputeNode solution to write xml messages into a flat file:

public void evaluate(MbMessageAssembly assembly) throws MbException {
MbOutputTerminal out = getOutputTerminal("out");
MbOutputTerminal alt = getOutputTerminal("alternate");

MbMessage inMessage = assembly.getMessage();
// create new message
MbMessage outMessage = new MbMessage(inMessage);
MbMessageAssembly outAssembly = new MbMessageAssembly(assembly,outMessage);

MbElement mqmdHeader = outAssembly.getMessage().getRootElement().getFirstChild().getNextSibling();;
mqmdHeader.detach();
MbMessage msg = outAssembly.getMessage();
byte[] bitstream = msg.getBuffer();

// ----------------------------------------------------------
// Add user code below
//PrintWriter streamFile;

try
{
FileOutputStream outputStream = new FileOutputStream("/file");
outputStream.write(bitstream);
outputStream.close();

}
catch(IOException exc)
{
System.out.println("Erreur d'ouverture");
}

message to the 'out' terminal

out.propagate(assembly);
}



Thanks for IBM experts help!
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Tue Oct 10, 2006 8:07 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Okay.

You're doing
Code:

MbMessage inMessage = assembly.getMessage();
// create new message
MbMessage outMessage = new MbMessage(inMessage);
properly to create a message tree that you can edit.

But then you ignore that and do
Code:
 MbElement mqmdHeader = outAssembly.getMessage()...
.

Try
Code:
 MbElement mqmdHeader = outMessage.getRootElement().getFirstChild().getNextSibling();

_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
cmmatei
PostPosted: Tue Oct 10, 2006 9:47 am    Post subject: Reply with quote

Apprentice

Joined: 06 Feb 2006
Posts: 26
Location: PARIS/NEW YORK

Sorry... I wasn't very clear in my last post.
The code I put in my last message works very well.

Thanks for your help!

Back to top
View user's profile Send private message
chids
PostPosted: Tue Oct 10, 2006 11:29 pm    Post subject: Reply with quote

Novice

Joined: 09 Oct 2006
Posts: 22
Location: Stockholm, Sweden

As you've noticed the MbAssembly, and the contained message, that are passed in to your comput node are read only. To modify the assembly (except for the global env which is always mutable) or the message you need to make a copy and work on that.
_________________
/mårten.
-- http://marten.gustafson.pp.se/
-- marten.gustafson@gmail.com
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » JavaCompute Node detach()
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.