我試圖通過下面的try catch塊的幫助來查找是否存在駱駝直接路由。我正在尋找一個謂詞來檢查路線是否存在於駱駝中。我無法找到任何東西,直接給我的答案,所以我採取了以下做法,如何檢查apache駱駝路線是否存在?
<doTry>
<recipientList>
<description>Check if a country specific handler is available</description>
<simple>direct:${header.operationName}${body.country}</simple>
</recipientList>
<doCatch>
<exception>org.apache.camel.component.direct.DirectConsumerNotAvailableException</exception>
<recipientList>
<description>if a country specific handler is not available to to the base</description>
<simple>direct:${header.operationName}</simple>
</recipientList>
</doCatch>
</doTry>
這意味着我不得不使用異常處理程序中的駱駝趕着DirectConsumerNotAvailableException,以確定是否路由存在。我期待在另一種方法,我們可以用一個簡單的語句,比如存在以下,
<choice>
<when>
<description>Check if a country specific handler is available</description>
<simple>direct:${header.operationName}${body.country} exists</simple>
<recipientList>
<description>country specific handler is available</description>
<simple>direct:${header.operationName}${body.country}</simple>
</recipientList>
</when>
<otherwise>
<recipientList>
<description>country specific handler is not available then route to generic processing</description>
<simple>direct:${header.operationName}</simple>
</recipientList>
</otherwise>
</choice>
請讓我知道是否可以使用一些其他方式來實現這樣的事情。
我編輯了這個問題使用recipientList –