0

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?

Chris
  • 4,325
  • 11
  • 51
  • 70

1 Answers1

2

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.

Tim Bish
  • 17,475
  • 4
  • 32
  • 42
  • 1
    Thank you very much, your answer solved my problem! But it is interesting that I can set the message properties via the setter class and other things too, but not the priority. – Chris Oct 13 '11 at 16:57
  • You can refer to the JMS API documentation on things like this, the various setters are tagged to indicate which one's are not applicable to sent Messages – Tim Bish Oct 14 '11 at 10:47