Camel successor example in xml DSL

How can I implement the following predicate example given in Spring DSL:

Predicate isWidget = header("type").isEqualTo("widget");

from("jms:queue:order")
   .choice()
      .when(isWidget).to("bean:widgetOrder")
      .when(isWombat).to("bean:wombatOrder")
   .otherwise()
      .to("bean:miscOrder")
   .end();
+5
source share
2 answers

Like this:

<route>
  <from uri="jms:queue:order"/>
  <choice>
    <when>
       <simple>${header.type} == 'widget'</simple>
       <to uri="bean:widgetOrder"/>
    </when>
    <when>
      <simple>${header.type} == 'wombat'</simple>
      <to uri="bean:wombatOrder"/>
    </when>
    <otherwise>
      <to uri="bean:miscOrder"/>
    </otherwise>
  </choice>
</route>
+4
source

Simple element required (see accepted answer )

<simple>${header.type} == 'widget'</simple>

Note that the field expression is surrounded by $ {}, followed by OGNL syntax for comparison, which is not part of the field expression itself.

+6
source

All Articles