[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How can we get/set the message body in an Artemis transformer?

On the server, the messages are not implementing JMS.

There's a wrapper used by the AMQP Converter. ServerJMSMessage with
sub classes as ServerJMSTextMessage... etc...

if you're happy by just accessing the Buffer.. there are two methods
on the CoreMessage: getDataBuffer is the proper method to access the

If you are interested on changing the buffer at the server's.. beware
though as the message could be a large message.. and hence you won't
always have the buffer at the right place.. and it won't be as easy to
change it.

getBodyBuffer is your best choice on the CoreMessage.

on AMQP Land you can just mess up with the AMQP Body messages...
there's a method to reencode messages..

On Wed, May 9, 2018 at 4:50 PM, Arthur Naseef <art@xxxxxxxxxx> wrote:
> When working with javax.jms.Message, the typical solution is to detect and
> cast to the specific message type.
> For example:
> if (message instanceof TextMessage) {
>     TextMessage textMessage = (TextMessage) message;
>     textMessage.getText();
> }
> Hope this helps.
> Art
> On Wed, May 9, 2018 at 1:11 AM, Lionel Cons <lionel.cons@xxxxxxx> wrote:
>> The Transformer interface uses the Message class. It is very easy to
>> get/set
>> message properties. See for instance [1].
>> The Message class only contains deprected methods to get the message body
>> (getBodyBuffer() and getBodyInputStream()) and nothing to set it.
>> How can we set/get the message body from a transformer?
>> Here is a typical use case: the body contains a binary payload that needs
>> to
>> be decoded and replaced by an equivalent JSON payload.
>> Cheers,
>> Lionel
>> [1]
>> examples/features/standard/divert/src/main/java/org/
>> apache/activemq/artemis/jms/example/

Clebert Suconic