Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Minor spelling and grammar changes

...

Variable

Type

Description

exchangeId

String

Camel 2.3: the exchange id

id

String

the input message id

body

Object

the input body

in.body

Object

the input body

body.OGNL

Object

Camel 2.3: the input body invoked using a Camel OGNL expression.

in.body.OGNL

Object

Camel 2.3: the input body invoked using a Camel OGNL expression.

bodyAs(type)

Type

Camel 2.3: Converts the body to the given type determined by its classname. The converted body can be null.

mandatoryBodyAs(type)

Type

Camel 2.5: Converts the body to the given type determined by its classname, and expects the body to be not null.

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

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="93fb5149473d7164-3654053d-49c34989-bbf48372-2332002283d46af6c8064b62"><ac:plain-text-body><![CDATA[

header.foo[bar]

Object

Camel 2.3: regard input foo header as a map and perform lookup on the map with bar as key

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="0fa2f1b6275de1ee-fd909fb4-434548b2-983e9a5d-f808faf581c2810eee12c5e7"><ac:plain-text-body><![CDATA[

in.header.foo[bar]

Object

Camel 2.3: regard input foo header as a map and perform lookup on the map with bar as key

]]></ac:plain-text-body></ac:structured-macro>

<ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="10c5f86175d9ecdf-e0c5bc4c-47614137-97a29438-8581b3a7c298eb4db4aa078e"><ac:plain-text-body><![CDATA[

in.headers.foo[bar]

Object

Camel 2.3: regard input foo header as a map and perform lookup on the map with bar as key

]]></ac:plain-text-body></ac:structured-macro>

header.foo.OGNL

Object

Camel 2.3: refer to the input foo header and invoke its value using a Camel OGNL expression.

in.header.foo.OGNL

Object

Camel 2.3: refer to the input foo header and invoke its value using a Camel OGNL expression.

in.headers.foo.OGNL

Object

Camel 2.3: refer to the input foo header and invoke its value using a Camel OGNL expression.

out.header.foo

Object

refer to the out header foo

out.headers.foo

Object

refer to the out header foo

headerAs(key,type)

Type

Camel 2.5: Converts the header to the given type determined by its classname

property.foo

Object

refer to the foo property on the exchange

property.foo.OGNL

Object

Camel 2.8: refer to the foo property on the exchange and invoke its value using a Camel OGNL expression.

sys.foo

String

refer to the system property

sysenv.foo

String

Camel 2.3: refer to the system environment

exception

Object

Camel 2.4: Refer to the exception object on the exchange, is null if no exception set on exchange. Will fallback and grab caught exceptions (Exchange.EXCEPTION_CAUGHT) if the Exchange has any.

exception.OGNL

Object

Camel 2.4: Refer to the exchange exception invoked using a Camel OGNL expression object

exception.message

String

Camel 2.0. Refer to the exception.message on the exchange, is null if no exception set on exchange. Will fallback and grab caught exceptions (Exchange.EXCEPTION_CAUGHT) if the Exchange has any.

exception.stacktrace

String

Camel 2.6. Refer to the exception.stracktrace on the exchange, is null if no exception set on exchange. Will fallback and grab caught exceptions (Exchange.EXCEPTION_CAUGHT) if the Exchange has any.

date:command:pattern

String

Camel 1.5. Date formatting using the java.text.SimpleDataFormat 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

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.

properties:locations:key

String

Camel 2.3: Lookup a property with the given key. The locations option is optional. See more at Using PropertyPlaceholder.

threadName

String

Camel 2.3: Returns the name of the current thread. Can be used for logging purpose.

ref:xxx

Object

Camel 2.6: To lookup a bean from the Registry with the given id.

...

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 are supported:

Operator

Description

==

equals

>

greater than

>=

greater than or equals

<

less than

<=

less than or equals

!=

not equals

contains

For testing if contains in a string based value

not contains

For testing if not contains in a string based value

regex

For matching against a given regular expression pattern defined as a String value

not regex

For not matching against a given regular expression pattern defined as a String value

in

For matching if in a set of values, each element must be separated by comma.

not in

For matching if not in a set of values, each element must be separated by comma.

is

For matching if the left hand side type is an instanceof the value.

not is

For matching if the left hand side type is not an instanceof the value.

range

For matching if the left hand side is within a range of values defined as numbers: from..to

not range

For matching if the left hand side is not within a range of values defined as numbers: from..to

...

Info
titleComparing with different types

When you compare with different types such as String and int, then you have to take a bit care. Camel will use the type from the left hand side as 1st priority. And fallback to the right hand side type if both values couldn't be compared based on that type.
This means you can flip the values to enforce a specific type. Suppose the bar value above is a String. Then you can flip the equation:

Code Block
simple("100 < ${in.header.bar}")

which then ensures the int type is used as 1st priority.

This may change in the future if the Camel team improves and let the binary comparision comparison operations be smarter and to prefer numeric types over String based. It's most often the String type which causes problem when comparing with numbers.

...

Code Block
simple("${in.header.type} not in 'gold,silver'")

And you can test for if the type is a certain instance, eg for instance a String

...

Code Block
simple("${in.header.type} is String")

Ranges is are also supported. The range interval requires numbers and both from and end is are inclusive. For instance to test whether a value is between 100 and 199:

...

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 have 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>

...

And of course the or is also supported. The sample example would be:

Code Block
simple("${in.header.title} contains 'Camel' or ${in.header.type'} == 'gold'")

...

Notice that we must use ${ } placeholders in the expression now to let allow Camel be able to parse it correctly.

And this sample uses the date command to output current date.

...

Code Block
xml
xml
  <transform>
    <simple>Hello ${bodyAs(String)} how are you?</simple>
  </transform>

There is are a few types which have a shorthand notation, hence why so we can use String instead of java.lang.String. These are: byte[], String, Integer, Long. All other types must use their FQN name, e.g. org.w3c.dom.Document.

...

In the code above we lookup the header with name type and regard it as a java.util.Map and we then lookup with the key gold and return the value.
If the header is not convertible to Map an exception is thrown. If the header with name type does not exists exist null is returned.

Dependencies

...