我试图通过下面的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 –