"Simple" Expression Language - arithmetic operators?
apache-camel, java, simple-el
Solution
The Simple Languate included in Apache Camel does not support a `+` operation per-se. It offers however an `++` increment operator which requires the left hand side to be a function.
The easiest solution would be to refactor the operation to a bean
public class NextValueService {
@Handler
public Integer nextValue(Integer value) {
return value + 1;
}
}
and use it in your route as follows:
.when(simple("${body.updateSeq} > ${bean:nextValueService?method=nextValue(property.PrevUpdateSeq)"}))
.to("direct:someError")
Switching simple language with f.e. JavaScript or Groovy should also help on dealing with the problem.
Problem
I'm using this expression in a camel route: ``` .when(simple("${body.updateSeq} > ${property.PrevUpdateSeq} + 1")) .to("direct:someError") ``` However it is freaking out about the `+` symbol. ``` org.apache.camel.language.simple.types.SimpleIllegalSyntaxException: Unexpected token + at location 46 ${body.updateSeq} > ${property.PrevUpdateSeq} + 1 * ``` How can I construct this expression, giving that it takes a value from the getter `getUpdateSeq` of the POJO on the message body and compres it to a property on the Exchange (plus 1).