Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ActiveMQ:为消息设置优先级不起作用_C#_.net_Activemq_Nms - Fatal编程技术网

C# ActiveMQ:为消息设置优先级不起作用

C# ActiveMQ:为消息设置优先级不起作用,c#,.net,activemq,nms,C#,.net,Activemq,Nms,我无法通过nms设置消息优先级。消息被发送到队列,一切正常,但优先级被忽略 我使用以下代码: message.NMSPriority = MsgPriority.High; 无论我为消息优先级设置了什么值,使用ActiveMQ浏览器我都可以看到优先级始终设置为4 我还尝试添加一些原始标题,如: message.Properties["priority"] = 2; message.Properties["PRIORITY"] = 5; message.Properties["NMSPriori

我无法通过nms设置消息优先级。消息被发送到队列,一切正常,但优先级被忽略

我使用以下代码:

message.NMSPriority = MsgPriority.High;
无论我为消息优先级设置了什么值,使用ActiveMQ浏览器我都可以看到优先级始终设置为4

我还尝试添加一些原始标题,如:

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

我还添加了属性

prioritizedMessages="true"
到activemq.xml文件。我可以通过ActiveMQ浏览器手动发送具有优先级的消息


那么问题出在哪里呢?我做错了什么?

消息优先级始终由发送消息的生产者设置。类上的setter仅允许您在收到消息后更改值,并且通常仅用于单元测试或在提供者之间转换消息。要按每条消息设置消息优先级,请查看MessageProducer接口中的不同发送方法

非常感谢,你的回答解决了我的问题!但有趣的是,我也可以通过setter类和其他东西设置消息属性,但不能设置优先级。您可以参考JMS API文档中的类似内容,各种setter都被标记,以指示哪些setter不适用于发送的消息