Message Translator
Camel supports the Message Translator from the EIP patterns.

The Message Translator can be done in different ways in Camel:
-
Using template-based Components, with the template being the source for how the message is translated
-
Messages can also be transformed using Data Format to marshal and unmarshal messages in different encodings.
Example
Each of above approaches is documented in the following examples:
Message Translator with Transform EIP
You can use a Transform which uses an Expression to do the transformation:
In the example below we prepend Hello to the message body using the Simple language:
- Java
-
from("direct:cheese") .setBody(simple("Hello ${body}")) .to("log:hello");
- XML
-
<route> <from uri="activemq:cheese"/> <transform> <simple>Hello ${body}</simple> </transform> <to uri="activemq:wine"/> </route>
Message Translator with Bean
You can transform a message using Camels Bean Integration to call any method on a bean that performs the message translation:
- Java
-
from("activemq:cheese") .bean("myTransformerBean", "doTransform") .to("activemq:wine");
- XML
-
<route> <from uri="activemq:cheese"/> <bean ref="myTransformerBean" method="doTransform"/> <to uri="activemq:wine"/> </route>
Message Translator with Processor
You can also use a Processor to do the transformation:
- Java
-
from("activemq:cheese") .process(new MyTransformerProcessor()) .to("activemq:wine");
- XML
-
<route> <from uri="activemq:cheese"/> <process ref="myTransformerProcessor"/> <to uri="activemq:wine"/> </route>
Message Translator using Templating Components
You can also consume a message from one destination, transform it with something like Velocity or XQuery and then send it on to another destination.
- Java
-
from("activemq:cheese") .to("velocity:com/acme/MyResponse.vm") .to("activemq:wine");
- XML
-
<route> <from uri="activemq:cheese"/> <to uri="velocity:com/acme/MyResponse.vm"/> <to uri="activemq:wine"/> </route>
Message Translator using Data Format
See Marshal EIP for more details and examples.