Sunday, 12 November 2017

Compare Operation with Camel Spring DSL

We can use Camel simple expression to compare values.The following things will help to compare values while using simple

Operator
Description
==
Equals.
=~
equals ignore case (will ignore case when comparing values String).
>
Greater than.
>=
Greater than or equals.
<
Less than.
<=
Less than or equals.
!=
Not equals.

Example :

<route id="HELLO-WORLD">
<from uri="direct:hello.world" />
  <setHeader headerName="status">
<simple>SUCCESS</simple>
 </setHeader>
  <choice>
    <when>
      <simple>${headers.status} =~ 'success'</simple>
      <to uri="bean:helloWorld?method=process" />
    </when>
  </choice>
</route>
The above ${headers.status} =~ 'success' will return true . Because =~ compare the values with equals ignore case.

No comments:

Post a Comment