Set Body

Camel supports the Message Translator from the EIP patterns .

image

The Message Translator can be done in different ways in Camel:

This page is documenting the first approach by using Set Body EIP.

Options

The Set Body eip supports 0 options, which are listed below.

Name Description Default Type

description

Sets the description of this node.

String

disabled

Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime.

false

Boolean

expression

Required Expression that returns the new body to use.

ExpressionDefinition

Exchange properties

The Set Body eip has no exchange properties.

Examples

You can use a Set Body which uses an Expression to do the transformation:

In the example below, we prepend Hello to the message body using the Simple language:

  • Java

  • XML

from("direct:cheese")
    .setBody(simple("Hello ${body}"))
    .to("log:hello");
<route>
    <from uri="direct:cheese"/>
    <setBody>
        <simple>Hello ${body}</simple>
    </setBody>
    <to uri="log:hello"/>
</route>

What is the difference between Transform and Set Body?

The Transform EIP always sets the result on the OUT message body.

Set Body sets the result accordingly to the Exchange Pattern on the Exchange .