1
由於這個環節說dead-letter-channel我才知道消息的標題包含最高再交貨時間。駱駝重置REDELIVERY_MAX_COUNTER爲0或n不工作
Starting with 2.6: The header CamelRedeliveryMaxCounter, which is also defined on the Exchange.REDELIVERY_MAX_COUNTER, contains the maximum redelivery setting
所以我嘗試設置Exchange.REDELIVERY_MAX_COUNTER
至6
arg0.getIn().setHeader(Exchange.REDELIVERY_MAX_COUNTER,6);
int max =arg0.getIn().getHeader(Exchange.REDELIVERY_MAX_COUNTER, Integer.class);
System.out.println(max);
這是我的全部代碼
public class ActivemqRouteBuilder extends RouteBuilder {
@Override
public void configure() throws Exception {
from("activemq:queue:MyQueue")
.onException(IOException.class)
.maximumRedeliveries(2)
.redeliveryDelay(4000)
.handled(true)
.beanRef("msgPro2","SendMail")
.to("activemq:queue:MyQueue.DLQ")
.end()
.transacted()
.process(new Processor() {
@Override
public void process(Exchange arg0) throws Exception {
arg0.getIn().setHeader(Exchange.REDELIVERY_MAX_COUNTER,6);
int max = arg0.getIn().getHeader(Exchange.REDELIVERY_MAX_COUNTER, Integer.class);
System.out.println(max);
/*error producing code*/
}}
);
由於錯誤是那裏Processor()
消息被試圖將重新傳送的2倍,但我復位Exchange.REDELIVERY_MAX_COUNTER
到6倍,從而是假設消息進行重發的6倍但它不發生,而是它只能重複使用2次。但我可以在輸出中看到6,因爲我打印max
值。任何人都可以建議我會出現什麼問題?