How to use in operator in camel simple xml dsl?

1.7k Views Asked by At

I am using Camel 2.17.0. I have a need to use in operator in the simple language in the blueprint.xml file as the following

<choice id="_choice3"> <when id="_when3"> <simple>${header.STATUS} in 'Draft,Review'</simple> ......

However, It doesn't work and throws following exception:

org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-A5668784-61983-1579873128661-9-6] at org.apache.camel.util.ObjectHelper.wrapCamelExecutionException(ObjectHelper.java:1706) at org.apache.camel.builder.SimpleBuilder.createPredicate(SimpleBuilder.java:104) at org.apache.camel.builder.SimpleBuilder.matches(SimpleBuilder.java:83)

By the way, I have been using choice/when condition for a long time. Then I tried to use || and or operator as followings:

<simple>(${header.STATUS.contains("Draft")} or ${header.STATUS.contains("Review")})</simple>
<simple>(${header.STATUS} contains 'Draft' || ${header.STATUS} contains 'Review')</simple>
<simple>(${header.STATUS} contains 'Draft' or ${header.STATUS} contains 'Review')</simple>

In all cases, it throws the same exception. Please help. Thanks in advance

1

There are 1 best solutions below

1
On

you might lose those extra "()" (brackets) at the end. Could you try something like this

<simple>${header.STATUS} contains'Draft' or ${header.STATUS} contains 'Review'</simple>

I pre-assume that you are setting the Draft (String) value in the Header.

I hope it helps. :)