gpt4 book ai didi

java - Apache Camel 路线: onCompletion not reached when exception occurs?

转载 作者:行者123 更新时间:2023-12-01 09:40:54 26 4
gpt4 key购买 nike

我有一条 Camel 路线,如下所示。如果所有记录解析成功,我会收到来自 onCompletion 步骤的电子邮件。如果一条记录出现异常,则其余记录将得到处理,这很好,但 onCompletion 步骤不会触发。

我想要的是即使存在错误, onCompletion 步骤也能运行,并且能够发送一条消息说“路由已完成但有错误”。我怎样才能做到这一点?

        <route id="route1">
<from uri="file://C:/TEMP/load?noop=true&amp;idempotentRepository=#sysoutStore&amp;sorter=#externalDataFilesSorter"/>
<choice>
<when>
<simple>${file:name} regex '*file.*.(txt)'</simple>
<to uri="direct:RouteFile" />
</when>
</choice>
</route>

<route id="testRouteDirect">
<from uri="direct:RouteFile" />
<onException>
<exception>java.lang.IllegalArgumentException</exception>
<redeliveryPolicy maximumRedeliveries="1" />
<handled>
<constant>true</constant>
</handled>
<to uri="log:java.lang.IllegalArgumentException"></to>
</onException>
<onException>
<exception>java.text.ParseException</exception>
<redeliveryPolicy maximumRedeliveries="1" />
<handled>
<constant>true</constant>
</handled>
<to uri="log:java.text.ParseException"></to>
</onException>
<split parallelProcessing="false" strategyRef="exchangePropertiesAggregatorStrategy" >
<tokenize token="\r\n"/>
<to uri="log:Record"></to>
</split>
<onCompletion>
<to uri="log:completion"></to>
<to uri="smtp://mail.com?contentType=text/html&amp;to=done@test.com&amp;from=route@test.com&amp;subject=we're done" />
</onCompletion>
</route>

最佳答案

您的路线最好的部分是,您的路线内有 onException ,并且handled=true。因此,将您的 onCompletion 移至父路由(route1),它应该可以工作!

关于java - Apache Camel 路线: onCompletion not reached when exception occurs?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38462789/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com