Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: CAMEL-1338

...

Variable

Type

Description

id

String

the input message id

body

Object

the input body

in.body

Object

the input body

out.body

Object

the output body

header.foo

Object

refer to the input foo header

headers.foo

Object

refer to the input foo header

in.header.foo

Object

refer to the input foo header

in.headers.foo

Object

refer to the input foo header

out.header.foo

Object

refer to the out header foo

out.headers.foo

Object

refer to the out header foo

property.foo

Object

refer to the foo property on the exchange

sys.foo

String

refer to the system property

exception.message

String

New in Camel 2.0. Refer to the exception.messsage on the exchange, is <tt>null</tt> if no exception set on exchange

date:command:pattern

String

New in Camel 1.5. Date formatting using the java.text.SimepleDataFormat patterns. Supported commands are: now for current timestamp, in.header.xxx or header.xxx to use the Date object in the IN header with the key xxx. out.header.xxx to use the Date object in the OUT header with the key xxx.

bean:bean expression

Object

New in Camel 1.5. Invoking a bean expression using the Bean language. Specifying a method name you must use dot as separator. In Camel 2.0 we also support the ?method=methodname syntax that is used by the Bean component.

Operator support

Avaiable as of Camel 2.0
We added a basic set of operators supported in the simple language in Camel 2.0. The parser is limited to only support a single operator.

To enable it the left value must be enclosed in ${ }. The syntax is:

Code Block

${leftValue} OP rightValue

Where the rightValue can be a String literal enclosed in ' ', null, a constant value or another expression enclosed in ${ }.
Camel will automatically type convert the rightValue type to the leftValue type, so its able to eg. convert a string into a numeric so you can use > comparison for numeric values.

The following operators is supported:

  • ==
  • <
  • <=
  • >
  • >=
  • !=

Some examples:

Code Block

simple("${in.header.foo} == 'foo'")

// ' ' can be omitted
simple("${in.header.foo} == foo")

// here Camel will type convert '100' into the type of in.header.bar and if its an Integer '100' will also be converter to an Integer
simple("${in.header.bar} == '100'")

simple("${in.header.bar} == 100")

// 100 will be converter to the type of in.header.bar so we can do > comparison
simple("${in.header.bar} > 100")

// testing for not null
simple("${in.header.baz} != null")

And a bit more advanced example where the right value is another expression

Code Block

simple("${in.header.date} == ${date:now:yyyyMMdd}")

simple("${in.header.type} == ${bean:orderService?method=getOrderType}")
Tip
titleCan be used in Spring XML

As the Spring XML does not have all the power as the Java DSL with all its various builder methods, you had to resort to use some other languages
for testing with simple operators. Now you can do this with the simple language. In the sample below we want to test if the header is a widget order:

Code Block
xml
xml

    <from uri="seda:orders">
       <filter>
           <simple>in.header.type == 'widget'</simple>
           <to uri="bean:orderService?method=handleWidget"/>
       </filter>
    </from>

Samples

In the Spring XML sample below we filter based on a header value:

...