我的骆驼情境样本。
<camel:camelContext>
<camel:route id="r1">
<camel:from="someEndpoint"/>
...
<camel:to="to2"/>
</camel:route>
<camel:route id="r2">
<camel:from="to2"/>
...
<camel:to="to3"/>
</camel:route>
<camel:route id="r3">
<camel:from="to3"/>
...
<camel:to="to4"/>
</camel:route>
<camel:route id="r4">
<camel:from="to4"/>
...
<camel:to="exit"/>
</camel:route>
<camel:route id="errorProcessorRoute">
<camel:from="???"/>
...Some action...
<camel:to="exit"/>
</camel:route>
</camel:camelContext>
如果发生任何错误,我需要比procces路线 - &gt; errorProcessorRoute。
如何实施?
答案 0 :(得分:1)
<camel:errorHandler id="deadLetterErrorHandler" type="DeadLetterChannel" deadLetterUri="log:dead">
<camel:redeliveryPolicy maximumRedeliveries="2" redeliveryDelay="1000" logHandled="true" asyncDelayedRedelivery="true"/>
</camel:errorHandler>
来自here。
答案 1 :(得分:1)
如果要捕获任何错误,可以使用onException标记
<camel:camelContext>
....
<camel:route id="errorProcessorRoute">
<camel:from="direct:foo"/>
...Some action...
<camel:to="exit"/>
</camel:route>
<onException>
<exception>java.lang.Exception</exception>
<to uri="direct:foo"/>
</onException>
</camel:camelContext>