How to retry with delay in Camel(如何在骆驼中延迟重试)
问题描述
我有兴趣在 Camel 中使用 RedeliveryPolicy 在返回某个异常时重试将消息重新传递到端点.但是我似乎找不到很多如何配置它的示例.
I am interested in using RedeliveryPolicy in Camel to retry redelivery of a message to an endpoint when a certain exception is returned. But I cannot seem to find many examples of how to configure it.
目前我正在尝试:
from("direct:entry")
.onException(ResourceNotFoundException.class)
.redeliveryPolicy(new RedeliveryPolicy().delayPattern("delayPattern=0:" + aocmDelay + ",10:1000;15:2000:19:10000"))
.handled(true)
.end()
.to("direct:destination");
我的目标端点因 ResourceNotFoundException 而失败,但未调用 onException 处理并且重新传递未生效.关于我做错了什么的任何想法?
I have the destination endpoint failing with a ResourceNotFoundException but the onException handling is not being called and the redelivery does not take effect. Any ideas of what I am doing wrong?
推荐答案
您需要设置重新投递策略的单个属性.
You need to set the single properties of a redelivery policy.
from("direct:entry")
.onException(ResourceNotFoundException.class)
.maximumRedeliveries(20)
.delayPattern("1:2000;10:1000;15:2000;19:10000")
.handled(true)
.end()
.to("direct:destination");
补充意见:
- 您需要定义最大重新投递尝试次数(如果未在其他地方定义),否则使用默认值零
- 在延迟模式中,您有两个错别字
delayPattern=0:" + aocmDelay + ",10:1000;15:2000:19:10000
________________________________;_______________;________
- 重新发送计数从
1
开始,如果您定义0:1000;1:5000
,则第一次重新发送延迟 5 秒而不是 1 秒
- you need to define the maximum redelivery attempts (if not defined elsewhere) otherwise the default of zero is used
- in the delay pattern you had two typos
delayPattern=0:" + aocmDelay + ",10:1000;15:2000:19:10000
________________________________;_______________;________
- the redelivery count starts with
1
, if you define0:1000;1:5000
the first redelivery is delayed by five seconds not by one
这篇关于如何在骆驼中延迟重试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在骆驼中延迟重试


基础教程推荐
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 降序排序:Java Map 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01