Priority with activemq

We are currently developing an application using JMS and activemq (5.5.1). We would like to determine a higher priority for some messages that would make them consume first. After installing the producer and consumer (through spring (3.1) JMSTemplate), priority will not fully work. Indeed, when we “turn off” the consumer and send some messages, priority is respected, but when we add messages while the consumer is on, messages are received in the same order in which they were sent.

The configuration is pretty simple:

Priority has been activated in the activemq configuration file:

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

And the QoS setting was included in the manufacturer’s 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 simply change the priority property of the template on the manufacturer's side:

 template.setPriority(9); 

Any idea? Is this normal behavior, or is there some kind of configuration that we would forget?

+6
source share
2 answers

If you didn’t miss anything, I had a similar problem a couple of weeks ago (but with TTL and QPid).

At first, JMS does not build 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. 

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

So, what you see is actually normal.

In the process, you can use the Resequencer template, if it suits your business.

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

Here is another discussion on this topic:

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

+7
source

I know it's late, but the answers can help someone.

If you want your consumer to consume a message based on Priority Queue, you can use the message priority on the client side. This means that when messages are sent to your consumer (even before your consumer receives them using prefetching), they will be cached on the consumer side and priority by default. This is regardless of whether you use priority support on the broker's side. This can affect the order you see on the consumer, so just keep that in mind.

To enable it, set the following configuration parameter in your broker's URL, for example

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

To disable it, tcp://0.0.0.0:61616?jms.messagePrioritySupported=false

Therefore, you do not need to use Camel (if you want to avoid complications)

0
source

Source: https://habr.com/ru/post/905900/


All Articles