【发布时间】:2017-04-20 08:43:40
【问题描述】:
我有一个处理来自队列的消息的 Apache Camel 路由。为了更好地了解运行时发生的情况,我还将执行状态保存在数据库中(重试次数、上次执行状态……)。我想使用异常处理程序中的重新传递机制,但它会在每次更新数据库记录失败时执行一些处理。
from("jms:myinputqueue")
.onException(RetriableException.class)
.maximumRedeliveries(5)
.maximumRedeliveryDelay(10000)
.useOriginalMessage()
.to("log:store error information in database about each attempt") // (1)
.end() // onException
.to("log:apply business logic here which can throw exceptions")
;
第(1)部分只在所有重试都用尽后才执行,所以只执行一次。
我已阅读Apache Camel- Message Redelivery happens before onexception block executes,但建议的解决方案“onRedelivery”在新的重试开始之前执行。我需要存储每次失败的结果,以便将最后一个状态(错误消息)保存在数据库中。
有什么建议吗?
【问题讨论】:
标签: exception-handling apache-camel