Question

I have problems setting message priorities via nms. The messages are sent to the queue everything is ok but the priority is ignored.

I use the following code:

message.NMSPriority = MsgPriority.High;

Regardless what value I set for message priority, using the ActiveMQ browser I can see that the priority is always set to 4.

I also tried to add some raw headers like:

message.Properties["priority"] = 2;
message.Properties["PRIORITY"] = 5;
message.Properties["NMSPriority"] = 7;
message.Properties["JMSPriority "] = 9;

But it doesn't help.

I also have added the attribute

prioritizedMessages="true"

to the activemq.xml file. And I can send a message with priority manually via the ActiveMQ browser.

So where is the problem? What I am doing wrong?

Was it helpful?

Solution

Message priority is always set by the producer that sends the Message. The setter on the class will only allow you to change the value after you've received a message and is usually only used for unit testing or converting Messages between providers. To set Message priority on a per message basis have a look at the different send methods in the MessageProducer interface.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top