2016-09-22 136 views
0

我是駱駝新手,所以我的確有很多問題。在我尋求幫助之前,我會盡量仔細研究這個問題。在這個問題上我找不到解決方案。這可能是關鍵詞如此通用。在駱駝路線上時很複雜

我需要在路由上有條件。 (SOAP消息)在使用路由之前,標題中有兩個字段必須是特定值。我如何指定

if(x == 1 and y == 2) 

使用RouteBuilder?

回答

1

我認爲你可以使用簡單(http://camel.apache.org/simple)。你也可以查看謂詞(http://camel.apache.org/predicate.html)。

在XML-DSL它會是什麼樣子:

<choice> 
      <when><simple>${header.x} == '1' && ${header.y} == '2'</simple> 
       <log message="do something with message"/> 
      </when> 
      <otherwise> 
       <log message="do something else"/> 
      </otherwise> 
</choice> 
0

您可以使用謂詞。實現謂詞接口,並在選擇中使用謂詞。

from("direct:node1") 
       .choice() 
        .when(customPredicate) 
         .to("direct:node2"); 

謂詞的定義與您的用例完全相同。謂詞有助於使用謂詞中嵌入的複雜邏輯進行路由決策。