Might be better to avoid that altogether and just create a new message instance, copy what you need, etc etc
Right now I'd like to stick with trying to figure out the body-handling.
Here's what I came up with based on the source code. The code below works, but leads to more questions about Body manipulation:
System.out.println("Payload body type: " + Payload.bodyType(message));
MessagePayloadProxy mpp = new MessagePayloadProxy(_config);
o = mpp.getPayload(message);
System.out.println("Payload object type: " + o.getClass().getName());
System.out.println("Payload location: " + mpp.getSetPayloadLocation());
String newPayload = args + " " + args;
I still haven't been able to get Body.replace() to work but that might be because I don't understand what I'm trying to do.
I was able to instantiate a new message Body, but was not able to use it in Body.replace() (throws a message fault).
ObjectBody newBody = (ObjectBody)
I'm working with the first action handler processing a JMS message. The Payload.bodyType reported is "raw". I wasn't expecting that at all.
What's a "raw" body type? Could that be one reason that it can't be replaced with a different Body type?
Incidentally, I started in this direction because I was looking for a way to compensate for not being able to transmit attributes in a JMS MapMessage. I didn't want to have to burden the action with the overhead of XML parsing.
I just looked at the JMS ObjectMessage processing in the Trailblazer, and the "CSV" parsing with ConfigTree looks like a simple, lightweight solution to my problem. (I've been focusing on the quickstarts).
I saw a post that indicated that the Trailblazer was going to be removed from newer releases. It might be a good idea to include a quickstart that demonstrates that CSV processing.
Might I suggest you use the add method instead of replace? (See http://www.jboss.org/jbossesb/docs/4.2GA/javadoc/esb/org/jboss/soa/esb/message/Body.html#add%28java.lang.Object%29) If you use Body.add("") you end up with an empty String as the message content.
To be quite honest.... I wasn't even aware of the option to "replace" the message Body and even if I was, I'm not sure I'd ever use it. That message api is way too complex for my liking and is almost guaranteed to be simplified drastically in ESB 5.
Not sure why creating a new Message instance is not an option, but here's another option that may work... try replacing the message Body using the Body part from a newly created Message instance. If that does not work, then I strongly advice looking at other options to solving your use case (i.e. away from replacing the Body).
Not sure why creating a new Message instance is not an option...
I just thought that modifying the Body would be simpler. Guess not.
That message api is way too complex for my liking...
I'll drink to that!