English 中文(简体)
优先程度
原标题:Priority with activemq

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.

组合非常简单:

优先工作已在现成的汇合文档中启动:

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

生产者模板组合也使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>

为了发出一个高度优先的信息,我们只是改变生产者方面的模板优先财产:

template.setPriority(9);

任何想法? 难道这种正常行为,或者我们是否会忘记某种组合?

最佳回答

如果我的意见没有遗漏,我几周前就有一个类似的问题(但与TTL和QPid有关)。

首先,初等监查处并不严格:

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.

第二,积极 MQ没有执行优先权问题,他们说,它将在6.x版本中有所作为。

因此,你认为实际上正常。

作为一个工作方,如果符合你的情况,你可以采用恢复模式。

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

Here is another discussion on this subject:

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

问题回答

I know it is late but this answers may help somebody.

如果您希望消费者以优先权(Priority Queue)为基础消费信息,那么你可以优先使用客户方信息。 这意味着,如果电文被送给消费者(甚至在消费者收到电文之前,使用假装),则电文将贴在消费者一方,按违约排列。 不管你是否利用中间商的优先支持。 这可能会影响你对消费者所看到的次序,从而避免这种情况。

为了做到这一点,在你的中间商URL上设定了以下组合选择,例如:

tcp://0.0.0.0:61616?jms.messagePrioritySupported=true

否则,tcp://0.0.0.0:616?jms.messagePrioritySupported=false

因此,你不需要使用Camel(如果你想要避免工作复杂化的话)





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...