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
这篇关于如何在骆驼中延迟重试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在骆驼中延迟重试


- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01