如何在队列上设置 ActiveMQ redeliveryPolicy? [英] How to set the ActiveMQ redeliveryPolicy on a queue?

查看:46
本文介绍了如何在队列上设置 ActiveMQ redeliveryPolicy?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在队列上的 ActiveMQ 中设置 redeliveryPolicy?

How do I set the redeliveryPolicy in ActiveMQ on a Queue?

1) 在文档中,请参阅:activeMQ Redelivery,说明您应该在 ConnectionFactory 或 Connection 上设置它.但我想为不同的队列使用不同的值.

1) In the doc, see: activeMQ Redelivery, the explain that you should set it on the ConnectionFactory or Connection. But I want to use different value's for different Queue's.

2)除此之外,我似乎无法让它发挥作用.在 Spring 的连接工厂上设置它(我使用的是 activemq 5.4.2. 和 Spring 3.0),像这样似乎没有任何效果:

2) Apart from that, I don't seem to get it work. Setting it on the connection factory in Spring (I am using activemq 5.4.2. with Spring 3.0) like this don't seem to have any effect:

<amq:connectionFactory id="amqConnectionFactory" brokerURL="${jms.factory.url}" >
    <amq:properties>
        <amq:redeliveryPolicy maximumRedeliveries="6" initialRedeliveryDelay="15000" useExponentialBackOff="true" backOffMultiplier="5"/>
    </amq:properties>
</amq:connectionFactory>

我还尝试将其设置为已定义队列的属性,但这似乎也被忽略了,因为重新传递比定义的值发生得更快:

I also tried to set it as property on the defined Queue, but that also seem to be ignored as the redelivery occurs sooner that the defined values:

<amq:queue id="jmsQueueDeclarationSnd"  physicalName="${jms.queue.declaration.snd}" >
    <amq:properties>
        <amq:redeliveryPolicy maximumRedeliveries="6" initialRedeliveryDelay="15000" useExponentialBackOff="true" backOffMultiplier="5"/>
    </amq:properties>
</amq:queue>

谢谢

推荐答案

我按照上面的方法在工厂中设置它,但只有在将连接工厂创建为 Spring bean 而不是通过 XBean 时才能正常工作,如上所示.这是因为 xsd 不允许您将 redeliveryPolicy 设置为对象,而只能将其设置为字符串.在 Spring 的 DefaultMessageListenerContainer 中将缓存级别设置为 Consumer 后,一切正常.

I got it working by setting it on the factory as done above but only when creating the connection factory as a Spring bean and not through XBean as shown above. This is because the xsd doesn't allow you to set the redeliveryPolicy as an object, but merely as a String. After setting the cache level to Consumer in Spring's DefaultMessageListenerContainer, it all worked.

在队列上,您似乎可以简单地设置传递策略...奇怪,因为我想对不同的队列/主题进行不同的设置.试想一下,您有一个又慢又快的队列,或者您连接到的外部系统需要更多时间来恢复.也许这个功能还有待实现

On the queue , it seems that you simple can set a delivery policy... Strange, as I would like to have different settings for different queue's/topics. Just imagine you have a slow and faster queue, or a external system that you connect to that needs more time to recover.. Maybe this feature is still to be implemented

这篇关于如何在队列上设置 ActiveMQ redeliveryPolicy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆