Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed a ton of its vs it´s problems

...

The Simple Expression Language was a really simple language you can usewhen it was created, but has since grown more powerful. Its 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 its it is ideal for testing in camel-core. Its ideal 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.

...

Info
titleSimple 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 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 either 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 its 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'".

...

Code Block
simple("${body?.address?.street}")

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

...

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

...

Code Block
// exact equals match
simple("${in.header.foo} == 'foo'")
 
// 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 it itsis 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")

...

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

...

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 it is lost in the deep blue sea (wink).

...

Code Block
java
java
   from("direct:hello").transform().simple("The today is ${date:now:yyyyMMdd} and itsit is a great day.").to("mock:reply");

...

Where orderIdGenerator is the id of the bean registered in the Registry. If using Spring then its 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.

...

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

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

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 It is also possible to lookup a value from a header Map in Camel 2.3 onwards:

...

Available as of Camel 2.9.3

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

...