nic*_*pte 6 java spring activemq-classic jms
我们目前正在使用JMS和activemq(5.5.1)开发应用程序.我们希望为某些消息定义更高的优先级,这将使它们首先被消耗.设置生产者和消费者(通过spring(3.1)JMSTemplate)后,优先级不能完全发挥作用.实际上,当我们"关闭"消费者并发送一些消息时,优先级得到尊重,但是当我们在消费者开启时添加消息时,消息的接收顺序与发送消息的顺序相同.
配置很简单:
在activemq配置文件中激活优先级:
<policyEntries>
<policyEntry queue=">" prioritizedMessages="true"/>
...
</policyEntries>
Run Code Online (Sandbox Code Playgroud)
并且在生产者模板配置中启用了QoS:
<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>
Run Code Online (Sandbox Code Playgroud)
要发送具有高优先级的消息,我们只需更改生产者端的模板优先级属性:
template.setPriority(9);
Run Code Online (Sandbox Code Playgroud)
任何的想法?这是正常的行为,还是有一些我们会忘记的配置?
如果我的意见你没有遗漏任何东西,几周前我有一个类似的问题(但使用TTL和QPid).
首先,JMS对此不严格:
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.
Run Code Online (Sandbox Code Playgroud)
其次,ActiveMQ没有实现优先级队列,他们说它会在6.x版本的某个地方.
所以,你看到的实际上是正常的.
作为解决方法,如果适合您的情况,您可以使用Resequencer模式.
http://camel.apache.org/resequencer.html
这是关于这个主题的另一个讨论:
http://activemq.2283324.n4.nabble.com/Priority-message-td2352179.html
| 归档时间: |
|
| 查看次数: |
5860 次 |
| 最近记录: |