Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message processing with priorities [closed]

In a Java web application I have a recurring message load of type A (e.g., 20,000 every hour). Then I have a second type of messages (type B) that show up occasionally but have a higher priority than type A (say, 3,000). I want to be able to process these messages on one or more machines using open source software.

It seems to me that I could do that with JMS if I had a JMS server that would send messages from its queue based on priorities (e.g., send three message of type B and then one of type A even though all messages of type A are at the top of the message queue).

Do you know a JMS server that can do that - or do you know another way to implement this?

like image 598
Karsten Silz Avatar asked Dec 22 '08 21:12

Karsten Silz


2 Answers

The JMS standard supports message priorities default is 4, you can specify others). I think you need to set that in the message producer AND in the message itself (there are methods on both).

I think that ActiveMQ does support it.

However, many JMS broker have priority handling disabled by default. There is a flag that you may need to change, something like "supportJMSPriority", somewhere in the broker configuration.

Also, Apache Camel lets you write your own message resequencers so you could implement any form of priority that you would like.

like image 75
Uri Avatar answered Oct 28 '22 16:10

Uri


Set the message priority when you call "send(..)" on the MessageProducer (QueueSender, etc). Or, you can set the default priority on the MessageProducer from 0-9 (9 is highest). Setting the priority on the message itself won't work. It's overridden by the Producer.

Uri is correct--whether or not the priority is respected is implementation specific. I believe OpenJMS generally respects the priority out-of-the-box, but does not guarantee it.

JMS Spec states: "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."

like image 29
James Schek Avatar answered Oct 28 '22 16:10

James Schek