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?
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.'