与activemq优先 [英] Priority with activemq

查看:261
本文介绍了与activemq优先的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们当前正在使用JMS和activemq(5.5.1)开发应用程序. 我们想为某些消息定义更高的优先级,这将使它们首先被使用. 在设置了生产者和使用者之后(通过Spring(3.1)JMSTemplate),优先级不能完全发挥作用. 确实,当我们关闭"使用者并发送一些消息时,优先级得到了尊重,但是当我们在使用者打开时添加消息时,消息的接收顺序与发送时的顺序相同.

We're currentyly developping an application using JMS and activemq (5.5.1). We would like to define a higher priority for some messages, which would make them consumed first. After setting the producer and the consumer (through spring (3.1) JMSTemplate), the priority does not fully work. Indeed, when we "turn off" the consumer, and send some messages, the priority is respected, but when we add messages while the consumer is on, the messages are received in the same order they were sent.

配置非常简单:

在activemq配置文件中激活了优先级:

Priority was activated in the activemq config file:

<policyEntries>
  <policyEntry queue=">" prioritizedMessages="true"/>
  ...
</policyEntries>

并且在生产者模板配置中启用了QoS:

And QoS was enabled in the producer template configuration:

<bean id="jmsOCRTemplate" class="org.springframework.jms.core.JmsTemplate">
  <property name="connectionFactory" ref="connectionFactory" />
  <property name="defaultDestination" ref="destination_ocr" />
  <property name="explicitQosEnabled" value="true" />
</bean>

要发送高优先级的消息,我们只需在生产者端更改模板优先级属性:

To send a message with a high priority, we just change the template priority property on the producer side:

template.setPriority(9);

有什么主意吗?这是正常的行为,还是我们会忘记一些配置?

Any idea? Is this the normal behaviour, or is there some configuration we would have forgotten?

推荐答案

如果我认为您没有遗漏任何东西,那么几周前我也遇到过类似的问题(但使用TTL和QPid).

If my opinion you are not missing anything, I had a similar issue a couple of weeks ago (but with TTL and QPid).

首先,JMS对此并不严格:

First the JMS is not Strict about this :

JMS does not require that a provider strictly implement priority ordering of messages; however, it should do its best to deliver expedited messages ahead of normal messages.

第二,ActiveMQ尚未实现优先级队列,他们说它将在6.x版本中出现.

Second, ActiveMQ does not YET implement priority queues, they say it will somewhere in 6.x version.

所以,您看到的实际上是正常的.

So, what you see is actually normal.

作为一种变通办法,如果适合您的情况,可以使用Resequencer模式.

As a work-around you can use the Resequencer pattern if it fits your case.

http://camel.apache.org/resequencer.html

这是关于此主题的另一讨论:

Here is another discussion on this subject:

http://activemq.2283324.n4.nabble.com /Priority-message-td2352179.html

这篇关于与activemq优先的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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