...
To get the body of the in message: "body"
, or "in.body"
or "${body}"
.
A complex expression must use ${ } placeholders, such as: "Hello ${in.header.name} how are you?"
.
You can have multiple tokens in the same expression: "Hello ${in.header.name} this is ${in.header.me} speaking"
.
However you can not nest tokens (i.e. having another ${ } placeholder in an existing, is not allowed).
Samples
In the Spring XML sample below we filter based on a header value:
Code Block | ||||
---|---|---|---|---|
| ||||
<from uri="seda:orders">
<filter>
<simple>in.header.foo</simple>
<to uri="mock:fooOrders"/>
</filter>
</from>
{code:xml}
The Simple language can be used for the predicate test above in the filter, where we test if the in message has a {{foo}} header (a header with the key {{foo}} exists). If the expression evaluates to *true* then the message is routed to the {{mock:foo}} endpoint. And for *false* it is of course routed to {{mock:bar}} endpoint.
The same example in Java DSL:
{code:java}
from("seda:orders")
.filter().simple("in.header.foo").to("seda:fooOrders");
|
You can also use the simple language for simple text concatenations such as:
Code Block | ||||
---|---|---|---|---|
| ||||
from("direct:hello").transform().simple("Hello ${in.header.user} how are you?").to("mock:reply");
|
Notice that we must use ${ }placeholders in the expression now to let Camel be able to parse it correctly.
Dependencies
The Bean language is part of camel-core.