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

java-xml DSL中的 Camel 谓词示例

(java - Camel Predicate Example in xml DSL)

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

如何实现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
22
Konstantin V. Salikhov 2014-02-13 00:06:30

像这样:

<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>