This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Message Transformation
Skip to end of metadata
Go to start of metadata

Message Transformation

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

  • enrich or transform a message before it is sent to the message bus within the JMS provider
  • enrich or transform a message as it is received from the message bus but before it is dispatched to the consumer

So this allows you to turn an ObjectMessage into a TextMessage containing XML using some kind of XML marshalling technology like XStream or JAXB2.

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

  • No labels