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:5000the first redelivery is delayed by five seconds not by one
这篇关于如何在骆驼中延迟重试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在骆驼中延迟重试
基础教程推荐
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
