Set Property
The SetProperty EIP is used for setting an Exchange property.
An Exchange property is a key/value set as a Map on the org.apache.camel.Exchange instance. This is not for setting property placeholders. |
Options
The Set Property eip supports 0 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
note | Sets the note of this node. | String | |
description | Sets the description of this node. | String | |
disabled | Disables this EIP from the route. | false | Boolean |
name | Required Name of exchange property to set a new value. The simple language can be used to define a dynamic evaluated exchange property name to be used. Otherwise a constant name will be used. | String | |
expression | Required Expression to return the value of the message exchange property. | ExpressionDefinition |
Example
The following example shows how to set a property on the exchange in a Camel route:
-
Java
-
XML
-
YAML
from("direct:a")
.setProperty("myProperty", constant("test"))
.to("direct:b"); <route>
<from uri="direct:a"/>
<setProperty name="myProperty">
<constant>test</constant>
</setProperty>
<to uri="direct:b"/>
</route> - route:
from:
uri: direct:a
steps:
- setProperty:
name: myProperty
expression:
constant:
expression: test
- to:
uri: direct:b Setting an exchange property from another exchange property
You can also set an exchange property with the value from another exchange property.
In the example, we set the exchange property foo with the value from an existing exchange property named bar.
-
Java
-
XML
-
YAML
from("direct:a")
.setProperty("foo", exchangeProperty("bar"))
.to("direct:b"); <route>
<from uri="direct:a"/>
<setProperty name="foo">
<exchangeProperty>bar</exchangeProperty>
</setProperty>
<to uri="direct:b"/>
</route> - route:
from:
uri: direct:a
steps:
- setProperty:
name: foo
expression:
exchangeProperty:
expression: bar
- to:
uri: direct:b Setting an exchange property with the current message body
It is also possible to set an exchange property with a value from anything on the Exchange such as the message body, where we use the Simple language to refer to the message body:
-
Java
-
XML
-
YAML
from("direct:a")
.setProperty("myBody", simple("${body}"))
.to("direct:b"); <route>
<from uri="direct:a"/>
<setProperty name="myBody">
<simple>${body}</simple>
</setProperty>
<to uri="direct:b"/>
</route> - route:
from:
uri: direct:a
steps:
- setProperty:
name: myBody
expression:
simple:
expression: "${body}"
- to:
uri: direct:b