It is sometimes useful to transform a message inside the JMS provider. For example you may have an application that has been live for some time that uses ObjectMessage messages, but that you wish to convert to use XML payloads (to protect yourself from serialization issues).
So ActiveMQ in 4.2 onwards comes with a pluggable strategy called the MessageTransformer interface. This allows you to
For example there is the XStreamMessageTransformer which when it is configured on a ConnectionFactory will cause all ObjectMessage instances to be silently transformed to and from TextMessage instances on the wire. This can be very useful if you have non-Java clients wishing to communicate with your Java messages.
Using a MessageTransformer
To use a MessageTransformer you can install it on one of the following classes via the setTransformer() method
The transformer is inherited on child objects; so you can install a particular transformer on a connection factory and it will be inherited on all connections, sessions, producers, consumers