Warm tip: This article is reproduced from serverfault.com, please click

Camel Predicate Example in xml DSL

发布于 2012-05-10 13:07:32

How can I implement 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();
Questioner
Himanshu Yadav
Viewed
0
Konstantin V. Salikhov 2014-02-13 00:06:30

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>