[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?

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;


Hope this helps.


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/