设置队列策略不将过期消息发送到 Camel 端点上的死信队列
Set-up queue policy not to send expired message to Dead-Letter Queue on Camel endpoint
我有一个小的 Camel 路由,它只是将消息转发到另一个队列,其过期时间如下:
@Override
public void configure() throws Exception {
defaultOnException();
// Route all messages generated by system A (in OUTBOUND_A) to system B (INBOUND_B)
// @formatter:off
from("activemq:queue:OUTBOUND_A")
// ASpecificProcessor transform the coming message to another one.
.processor(new ASpecificProcessor())
.to("activemq:INBOUND_B?explicitQosEnabled=true&timeToLive={{b.inbound.message.ttl}}");
// @formatter:on
}
我需要在 INBOUND_B
中发布的消息是持久的,默认情况下,过期的消息在过期后进入 ActiveMQ.DLQ
队列。
我知道我可以用
修改 conf/activemq.xml
中的 ActiveMQ 配置
<policyEntry queue="INBOUND_B">
<!--
Tell the dead letter strategy not to process expired messages
so that they will just be discarded instead of being sent to
the DLQ
-->
<deadLetterStrategy>
<sharedDeadLetterStrategy processExpired="false" />
</deadLetterStrategy>
</policyEntry>
但我不想更改 ActiveMQ 配置(因为它需要重新启动),我想知道是否可以通过 Camel 端点配置发送此类策略?
不,ActiveMQ 代理端配置不能通过客户端更新,那会导致各种安全问题。如果您在代理上使用 runtime configuration plugin,您将需要更新代理配置并且可能不需要重新启动。
我有一个小的 Camel 路由,它只是将消息转发到另一个队列,其过期时间如下:
@Override
public void configure() throws Exception {
defaultOnException();
// Route all messages generated by system A (in OUTBOUND_A) to system B (INBOUND_B)
// @formatter:off
from("activemq:queue:OUTBOUND_A")
// ASpecificProcessor transform the coming message to another one.
.processor(new ASpecificProcessor())
.to("activemq:INBOUND_B?explicitQosEnabled=true&timeToLive={{b.inbound.message.ttl}}");
// @formatter:on
}
我需要在 INBOUND_B
中发布的消息是持久的,默认情况下,过期的消息在过期后进入 ActiveMQ.DLQ
队列。
我知道我可以用
修改conf/activemq.xml
中的 ActiveMQ 配置
<policyEntry queue="INBOUND_B">
<!--
Tell the dead letter strategy not to process expired messages
so that they will just be discarded instead of being sent to
the DLQ
-->
<deadLetterStrategy>
<sharedDeadLetterStrategy processExpired="false" />
</deadLetterStrategy>
</policyEntry>
但我不想更改 ActiveMQ 配置(因为它需要重新启动),我想知道是否可以通过 Camel 端点配置发送此类策略?
不,ActiveMQ 代理端配置不能通过客户端更新,那会导致各种安全问题。如果您在代理上使用 runtime configuration plugin,您将需要更新代理配置并且可能不需要重新启动。