Spring JMS Activemq-设置死信队列名称(DLQ) [英] Spring JMS Activemq - set dead letter queue-name (DLQ)
问题描述
我们在同一个ACTIVEMQ代理上运行3个不同的项目. 当前只有一个"DLQ"队列,我们想像这样为每个Web应用程序设置dlq:
We have 3 different projects that are running on the same ACTIVEMQ broker. Currently there is a single "DLQ" queue, we would like to set the dlq for each web application like so:
dlq_webapp1
dlq_webapp2
dlq_webapp3
这样,我们将对重试流程有更多控制.我们如何配置它像这样?这是我们的一些消息传递bean:
This way we will have more control on the retry flow. how can we configure it to be like so? here are some of our messaging beans:
<bean id="redeliveryConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${activemq_url}" />
<property name="redeliveryPolicy" ref="redeliveryPolicy" />
<property name="nonBlockingRedelivery" value="true" />
</bean>
<bean id="redeliveryCachingConnectionFactory"
class="org.springframework.jms.connection.CachingConnectionFactory"
p:targetConnectionFactory-ref="redeliveryConnectionFactory"
p:sessionCacheSize="10" />
<!-- Redelivery: retry after 3sec, 6sec,9sec,12sec,15sec finally put in
DLQ -->
<bean id="redeliveryPolicy" class="org.apache.activemq.RedeliveryPolicy">
<property name="queue" value="*" />
<property name="initialRedeliveryDelay" value="0" />
<property name="redeliveryDelay" value="3000" />
<property name="maximumRedeliveryDelay" value="3600000" />
<property name="maximumRedeliveries" value="5" />
<property name="useExponentialBackOff" value="true" />
<property name="backOffMultiplier" value="1" />
</bean>
<!-- A JmsTemplate instance that uses the cached connection and destination -->
<bean id="redeliveryJmsTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory" ref="redeliveryCachingConnectionFactory" />
<property name="messageConverter" ref="eventConverter" />
<property name="sessionTransacted" value="true" />
</bean>
推荐答案
我认为您需要在代理上配置deadLetterStrategy
.请参阅以下示例- ActiveMQ DLQ
I think you need to configure the deadLetterStrategy
at the broker. Please refer the examples at - ActiveMQ DLQ
您可以选择individualDeadLetterStrategy
,它为每个队列创建一个单独的DLQ(取决于目标策略).您可以为每个项目/应用程序使用不同的前缀.因此,每个项目/应用程序只能有一个使用者,该使用者使用所有以相应前缀开头的DLQ的DLQ消息(在创建使用者时使用通配符).
You can choose the individualDeadLetterStrategy
which creates a separate DLQ for each queue (depends upon your destination policy). You can have a different prefix for each of your project/application. So that you can have only one consumer per project/application which consumes the DLQ messages from all DLQs starting with the respective prefix (use wildcards while creating consumer).
这篇关于Spring JMS Activemq-设置死信队列名称(DLQ)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!