Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 62DC31958B for ; Sun, 20 Mar 2016 20:19:35 +0000 (UTC) Received: (qmail 60389 invoked by uid 500); 20 Mar 2016 20:19:35 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 60345 invoked by uid 500); 20 Mar 2016 20:19:35 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 60336 invoked by uid 99); 20 Mar 2016 20:19:35 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 20 Mar 2016 20:19:35 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id B590018051F for ; Sun, 20 Mar 2016 20:19:34 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.799 X-Spam-Level: * X-Spam-Status: No, score=1.799 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id zD8N5JnVOUyH for ; Sun, 20 Mar 2016 20:19:21 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 05A345F21F for ; Sun, 20 Mar 2016 20:19:20 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 13792E0CBC for ; Sun, 20 Mar 2016 20:19:19 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id E52B73A1095 for ; Sun, 20 Mar 2016 20:19:18 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r983271 [4/7] - in /websites/production/camel/content: book-component-appendix.html book-in-one-page.html book-languages-appendix.html cache/main.pageCache ftp.html ftp2.html simple.html Date: Sun, 20 Mar 2016 20:19:18 -0000 To: commits@camel.apache.org From: buildbot@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20160320201918.E52B73A1095@svn01-us-west.apache.org> Modified: websites/production/camel/content/book-languages-appendix.html ============================================================================== --- websites/production/camel/content/book-languages-appendix.html (original) +++ websites/production/camel/content/book-languages-appendix.html Sun Mar 20 20:19:18 2016 @@ -904,7 +904,7 @@ result = body * 2 + 1 </dependency> ]]> -

Simple Expression Language

The Simple Expression Language was a really simple language you can use, but has since grown more powerful. Its primarily intended for being a really small and simple language for evaluating Expression and Predicate without requiring any new dependencies or knowledge of XPath; so its ideal for testing in camel-core. Its ideal to cover 95% of the common use cases when you need a little bit of expression based script in your Camel routes.

However for much more complex use cases you are generally recommended to choose a more expressive and powerful language such as:

The simple language uses ${body} placeholders for complex expressions where the expression contains constant literals. The ${ } placeholders can be omitted if the expression is only the token itself.

Alternative syntax

From Camel 2.5 onwards you can also use the alternative syntax which uses $simple{ } as placeholders.
This can be used in situations to avoid clashes when using for example Spring property placeholder together with Camel.

Configuring result type

From Camel 2.8 onwards you can configure the result type of the Simple expression. For example to set the type as a java.lang.Boolean or a java.lang.Integer etc.

File language is now merged with Simple language

From Camel 2.2 onwards, the File Language is now merged with Simple language which means you can use all the file syntax directly within the simp le language.

Simple Language Changes in Camel 2.9 onwards

The Simple language have been improved from Camel 2.9 onwards to use a better syntax parser, which can do index precise error messages, so you know exactly what is wrong and where the problem is. For example if you have made a typo in one of the operators, then previously the parser would not be able to detect this, and cause the evaluation to be true. There is a few changes in the syntax which are no longer backwards compatible. When using Simple language as a Predicate then the literal text must be enclosed in either single or do uble quotes. For example: "${body} == 'Camel'". Notice how we have single quotes around the literal. The old style of using "body" and "header.foo" to refer to the message body and header is @deprecated, and its encouraged to always use ${ } tokens for the built-in functions.
The range operator now requires the range to be in single quote as well as shown: "${header.zip} between '30000..39999'".

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 functions in the same expression: "Hello ${in.header.name} this is ${in.header.me} speaking".
However you can not nest functions in Camel 2.8.x or older (i.e. having another ${ } placeholder in an existing, is not allowed).
From Camel 2.9 onwards you can nest functions.

Variables

Variable

Type

Description

camelId

String

Camel 2.10: the CamelContext name

camelContext.OGNL

Object

Camel 2.11: the CamelContext invoked using a Camel OGNL expression.

exchangeExchangeCamel 2.16: the Exchange
exchange.OGNLObjectCamel 2.16: the Exchange invoked using a Camel OGNL expression.

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.OGN L

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

header[foo]

Object

Camel 2.9.2: refer to the input foo header

headers.foo

Object

refer to the input foo header

headers[foo]

Object

Camel 2.9.2: refer to the input foo header

in.header.foo

Object

refer to the input foo header

in.header[foo]

Object

Camel 2.9.2: refer to the input foo header

in.headers.foo

Object

refer to the input foo header

in.headers[foo]

Object

Camel 2.9.2: refer to the input foo header

header.foo[bar]

Object

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

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

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

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

O bject

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.header[foo]

Object

Camel 2.9.2: refer to the out header foo

out.headers.foo

Object

refer to the out header foo

out .headers[foo]

Object

Camel 2.9.2: refer to the out header foo

headerAs(key,type)

Type

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

headers

Map

Camel 2.9: refer to the input headers

in.headers

Map

Camel 2.9: refer to the input headers

property.foo

Object

Deprecated: refer to the foo property on the exchange

exchangeProperty.fooObjectCamel 2.15: refer to the foo property on the exchange

property[foo]

Object

Deprecated: refer to the foo property on the exchange

exchangeProperty[foo]ObjectCamel 2.15: refer to the foo property on the exchange

property.foo.OGNL

Object

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

exchangeProperty.foo.OGNLObjectCamel 2.15: 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

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

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

Invoking a bean expression using the Bean language. Specifying a method nam e you must use dot as separator. We also support the ?method=methodname syntax that is used by the Bean component.

properties:locations:key

String

Deprecated (use properties-location instead) Camel 2.3: Lookup a property with the given key. The locations option is optional. See more at Using PropertyPlaceholder.

properties-location:locations:key

String

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

properties:key:defaultStringCamel 2.14.1: Lookup a property with the given key. If the key does not exists or has no value, then an optional default value can be specified.

routeId

String

Camel 2.11: Returns the id of the current route the Exchange is being routed.

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.

type:name.field

Object

Camel 2.11: To refer to a type or field by its FQN name. To refer to a field you can append .FIELD_NAME. For example you can refer to the constant field from Exchange as: org.apache.camel.Exchange.FILE_NAME

.

null

null

Camel 2.12.3: represents a null

random(value)

Integer

Camel 2.16.0: returns a random Integer between 0 (included) and value (excluded)

random(min,max)

Integer

Camel 2.16.0: returns a random Integer between min (included) and max (excluded)

collate(group)ListCamel 2.17: The collate function iterates the message body and groups the data into sub lists of specified size. This can be used with the Splitter EIP to split a message body and group/batch the splitted sub message into a group of N sub lists. This method works similar to the collate method in Groovy.
messageHistoryStringCamel 2.17: The message history of the current exchange how it has been routed. This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception.
messageHist ory(false)StringCamel 2.17: As messageHistory but without the exchange details (only includes the route strack-trace). This can be used if you do not want to log sensitive data from the message itself.

OGNL expression support

Available as of Camel 2.3

Camel's OGNL support is for invoking methods only. You cannot access fields.
From Camel 2.11.1 onwards we added special support for accessing the length field of Java arrays.

The Simple and Bean language now supports a Camel OGNL notation for invoking beans in a chain like fashion.
Suppose the Message IN body contains a POJO which has a getAddress() method.

Then you can use Camel OGNL notation to access the address object:

+

Simple Expression Language

The Simple Expression Language was a really simple language when it was created, but has since grown more powerful. It is primarily intended for being a really small and simple language for evaluating Expressions and Predicates without requiring any new dependencies or knowledge of XPath; so it is ideal for testing in camel-core. The idea was to cover 95% of the common use cases when you need a little bit of expression based script in your Camel routes.

However for much more complex use cases you are generally recommended to choose a more expressive and powerful language such as:

The simple language uses ${body} placeholders for complex expressions where the expression contains constant literals. The ${ } placeholders can be omitted if the expression is only the token itself.

Alternative syntax

From Camel 2.5 onwards you can also use the alternative syntax which uses $simple{ } as placeholders.
This can be used in situations to avoid clashes when using for example Spring property placeholder together with Camel.

Configuring result type

From Camel 2.8 onwards you can configure the result type of the Simple expression. For example to set the type as a java.lang.Boolean or a java.lang.Integer etc.

File language is now merged with Simple language

From Camel 2.2 onwards, the File Language is now merged with Simple language which means you can use all the file syntax directl y within the simple language.

Simple Language Changes in Camel 2.9 onwards

The Simple language have been improved from Camel 2.9 onwards to use a better syntax parser, which can do index precise error messages, so you know exactly what is wrong and where the problem is. For example if you have made a typo in one of the operators, then previously the parser would not be able to detect this, and cause the evaluation to be true. There are a few changes in the syntax which are no longer backwards compatible. When using Simple language as a Predicate then the literal text must be enclosed in e ither single or double quotes. For example: "${body} == 'Camel'". Notice how we have single quotes around the literal. The old style of using "body" and "header.foo" to refer to the message body and header is @deprecated, and it is encouraged to always use ${ } tokens for the built-in functions.
The range operator now requires the range to be in single quote as well as shown: "${header.zip} between '30000..39999'".

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 functions in the same expression: "Hello ${in.header.name} this is ${in.header.me} speaking".
However you can not nest functions in Camel 2.8.x or older (i.e. having another ${ } placeholder in an existing, is not allowed).
From Camel 2.9 onwards you can nest functions.

Variables

collate(group)

Variable

Type

Description

camelId

String

Camel 2.10: the CamelContext name

camelContext.OGNL

Object

Camel 2.11: the CamelContext invoked using a Camel OGNL expression.

exchangeExchangeCamel 2.16: the Exchange
exchange.OGNLObjectCamel 2.16: the Exchange invoked using a Camel OGNL expression.

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

header[foo]

Object

Camel 2.9.2: refer to the input foo header

headers.foo

Object

refer to the input foo header

headers[foo]

Object

Camel 2.9.2: refer to the input foo header

in.header.foo

Object

refer to the input foo header

in.header[foo]

Object

Camel 2.9.2: refer to the input foo header

in.headers.foo

Object

refer to the input foo header

i n.headers[foo]

Object

Camel 2.9.2: refer to the input foo header

header.foo[bar]

Object

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

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

in.headers.foo[bar]

Objec t

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

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.header[foo]

Object

Camel 2.9.2: refer to the out header foo

out.headers.foo

Object

refer to the out header foo

out.headers[foo]

Object

Camel 2.9.2: refer to the out header foo

headerAs(key,type)

Type

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

headers

Map

Camel 2.9: refer to the input headers

in.headers

Map

Camel 2.9: refer to the input headers

property.foo

Object

Deprecated: refer to the foo property on the exchange

exchangeProperty.fooObjectCamel 2.15: refer to the foo property on the exchange

property[foo]

Object

Deprecated: refer to the foo property on the exchange

exchangeProperty[foo]< /span>ObjectCamel 2.15: refer to the foo property on the exchange

property.foo.OGNL

Object

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

exchangeProperty.foo.OGNLObjectCamel 2.15: 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

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 fall back and grab caught exceptions (Exchange.EXCEPTION_CAUGHT) if the Exchange has any.

date:command:pattern

String

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

Invoking a bean expression using the Bean language. Spe cifying a method name you must use dot as separator. We also support the ?method=methodname syntax that is used by the Bean component.

properties:locations:key

String

Deprecated (use properties-location instead) Camel 2.3: Lookup a property with the given key. The locations option is optional. See more at Using PropertyPlaceholder.

properties-location:locations:key

String

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

properties:key:defaultStringCamel 2.14.1: Lookup a property with the given key. If the key does not exists or has no value, then an optional default value can be specified.

routeId

String

Camel 2.11: Returns the id of the current route the Exchange is being routed.

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.

type:name.field

Object

Camel 2.11: To refer to a type or field by its FQN name. To refer to a field you can append .FIELD_NAME. For example you can refer to the constant field from Exchange as: org.apache.camel.Exchange.FILE_NAME

.

null

null

Camel 2.12.3: represents a null

random(value)

Integer

Camel 2.16.0: returns a random Integer between 0 (included) and value (excluded)

random(min,max)

Integer

Camel 2.16.0: returns a random Integer between min (included) and max (excluded)

ListCamel 2.17: The collate function iterates the message body and groups the data into sub lists of specified size. This can be used with the Splitter EIP to split a message body and group/batch the splitted sub message into a group of N sub lists. This method works similar to the collate method in Groovy.
messageHistoryStringCamel 2.17: The message history of the current exchange how it has been routed. This is similar to the route stack-trace message history the error handler logs in case of an unhandled exception.
messageHistory(false)StringCamel 2.17: As messageHistory but without the exchange details (only includes the route strack-trace). This can be used if you do not want to log sensitive data from the message itself.

OGNL expression support

Available as of Camel 2.3

Camel's OGNL support is for invoking methods only. You cannot access fields.
From Camel 2.11.1 onwards we added special support for accessing the length field of Java arrays.

T he Simple and Bean language now supports a Camel OGNL notation for invoking beans in a chain like fashion.
Suppose the Message IN body contains a POJO which has a getAddress() method.

Then you can use Camel OGNL notation to access the address object:

-

Its also possible to index in Map or List types, so you can do:

+

It is also possible to index in Map or List types, so you can do:

To assume the body is Map based and lookup the value with foo as key, and invoke the getName method on that value.

If the key has space, then you must enclose the key with quotes, for example 'foo bar':

@@ -960,7 +960,7 @@ simple("There are ${body.length} li

Operator support

The parser is limited to only support a single operator.

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

-

Where the rightValue can be a String literal enclosed in ' ', null, a constant value or another expression enclosed in ${ }.

Important

There must be spaces around the operator.

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

Operator

Description

==

equals

=~Camel 2.16: equals ignore case (will ignore case when comparing String values)

>

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. From Camel 2.9 onwards th e range values must be enclosed in single quotes.

not range

For matching if the left hand side is not within a range of values defined as numbers: from..to. From Camel 2.9 onwards the range values must be enclosed in single quotes.

And the following unary operators can be used:

Operator

Description

++

Camel 2.9: To increment a number by one. The left hand side must be a function, otherwise parsed as literal.

--

Camel 2.9: To decrement a number by one. The left hand side must be a function, otherwise parsed as literal.

\

Camel 2.9.3 to 2.10.x To escape a value, eg \$, to indicate a $ sign. Special: Use \n for new line, \t for tab, and \r for carriage return. Notice: Escaping is not supported using the File Language. Notice: From Camel 2.11 onwards the escape character is no longer support, but replaced with the following three special escaping.

\n

Camel 2.11: To use newline character.

\t

Camel 2.11: To use tab character.

\r

Camel 2.11: To use carriage return character.

And the following logical operators can be used to group expressions:

Operator

Description

and

deprecated use && instead. The logical and operator is used to group two expressions.

or

deprecated use || instead. The logical or operator is used to group two expressions.

&&

Camel 2.9: The logical and operator is used to group two expressions.

||

Camel 2.9: The logical or operator is used to group two expressions.

Using and,or operators

In Camel 2.4 or older the and or or can only be used once in a simple language expression. From Camel 2.5 onwards you can use these operators multiple times.

The syntax for AND is:

+

Where the rightValue can be a String literal enclosed in ' ', null, a constant value or another expression enclosed in ${ }.

Important

There must be spaces around the operator.

Camel will automatically type convert the rightValue type to the leftValue type, so it is able to eg. convert a string into a numeric so you can use > comparison for numeric values.

The following operators are supported:

Operator

Description

==

equals

=~Camel 2.16: equals ignore case (will ignore case when comparing String values)

>

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. From Camel 2.9 onwards the range values must be enclosed in single quotes.

not range

For matching if the left hand side is not within a range of values defined as numbers: from..to. From Camel 2.9 onwards the range values must be enclosed in single quotes.

And the following unary operators can be used:

Operator

Description

++

Camel 2.9: To increment a number by one. The left hand side must be a function, otherwise parsed as literal.

--

Camel 2.9: To decrement a number by one. The left hand side must be a function, otherwise parsed as literal.

\

Camel 2.9.3 to 2.10.x To escape a value, eg \$, to indicate a $ sign. Special: Use \n for new line, \t for tab, and \r for carriage return. Notice: Escaping is not supported using the File Language. Notice: From Camel 2.11 onwards the escape character is no longer support, but replaced with the following three special escaping.

\n

Camel 2.11: To use newline character.

\t

Camel 2.11: To use tab character.

\r

Camel 2.11: To use carriage return character.

And the following logical operators can be used to group expressions:

Operator

Description

and

deprecated use && instead. The logical and operator is used to group two expressions.

or

deprecated use || instead. The logical or operator is used to group two expressions.

&&

Camel 2.9: The logical and operator is used to group two expressions.

||

Camel 2.9: The logical or operator is used to group two expressions.

Using and,or operators

In Camel 2.4 or older the and or or can only be used once in a simple language expression. From Camel 2.5 onwards you can use these operators multiple times.

The syntax for AND is:

And the syntax for OR is:

@@ -973,7 +973,7 @@ simple("${in.header.foo} == 'fo // ignore case when comparing, so if the header has value FOO this will match 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 +// here Camel will type convert '100' into the type of in.header.bar and if it is an Integer '100' will also be converter to an Integer simple("${in.header.bar} == '100'") simple("${in.header.bar} == 100") @@ -1017,7 +1017,7 @@ simple("${in.header.type} == ${bean

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

-

Notice we use .. in the range without spaces. Its based on the same syntax as Groovy.

From Camel 2.9 onwards the range value must be in single quotes

+

Notice we use .. in the range without spaces. It is based on the same syntax as Groovy.

From Camel 2.9 onwards the range value must be in single quotes

Can 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 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:

@@ -1045,7 +1045,7 @@ simple("${in.header.type} == ${bean </filter> </from> ]]> -

The Simple language can be used for the predicate test above in the Message Filter pattern, 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:fooOrders endpoint, otherwise its lost in the deep blue sea (wink).

The same example in Java DSL:

+

The Simple language can be used for the predicate test above in the Message Filter pattern, 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:fooOrders endpoint, otherwise it is lost in the deep blue sea (wink).

The same example in Java DSL:

@@ -1053,23 +1053,23 @@ simple("${in.header.type} == ${bean

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

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

-

And in the sample below we invoke the bean language to invoke a method on a bean to be included in the returned string:

-

Where orderIdGenerator is the id of the bean registered in the Registry. If using Spring then its the Spring bean id.

If we want to declare which method to invoke on the order id generator bean we must prepend .method name such as below where we invoke the generateId method.

+

Where orderIdGenerator is the id of the bean registered in the Registry. If using Spring then it is the Spring bean id.

If we want to declare which method to invoke on the order id generator bean we must prepend .method name such as below where we invoke the generateId method.

We can use the ?method=methodname option that we are familiar with the Bean component itself:

-

And from Camel 2.3 onwards you can also convert the body to a given type, for example to ensure its a String you can do:

+

And from Camel 2.3 onwards you can also convert the body to a given type, for example to ensure that it is a String you can do:

-

There are a few types which have a shorthand notation, 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.

Its also possible to lookup a value from a header Map in Camel 2.3 onwards:

+

There are a few types which have a shorthand notation, 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.

It is also possible to lookup a value from a header Map in Camel 2.3 onwards:

-

Using new lines or tabs in XML DSLs

Available as of Camel 2.9.3

From Camel 2.9.3 onwards its easier to specify new lines or tabs in XML DSLs as you can escape the value now

+

Using new lines or tabs in XML DSLs

Available as of Camel 2.9.3

From Camel 2.9.3 onwards it is easier to specify new lines or tabs in XML DSLs as you can escape the value now