JMS消息优先级不适用于消息 [英] JMS message priority not working on Message

查看:126
本文介绍了JMS消息优先级不适用于消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置消息优先级,以便在接收方接收低优先级消息之前先消耗高优先级消息。

I need to set message priority so that High priority messages are consumed before Low priority messages by Receivers.

首先,我尝试使用message.setJMSPriority()方法进行设置优先级,但是它在HornetQ和ActiveMQ中不起作用,所以最后我使用setPriority()方法设置了消息产生器的优先级,现在它可以正常工作。

First I tried with message.setJMSPriority() method to set the priority but it was not working in HornetQ and ActiveMQ so finally I set the priority of the Message Producer using setPriority() method and it works fine now.

为什么不是' •Messsge.setJMSPriority()可在任何JMS供应商实现中使用,为什么我们需要设置生产者的优先级而不是消息本身来设置消息的优先级?那么Messsge.setJMSPriority()方法的用途是什么?

Why isn't Messsge.setJMSPriority() working in any of the JMS vendor implementations and why do we need to set the priority of the Producer not the message itself to set the priority of the message? What is the use of Messsge.setJMSPriority() method then?

任何建议或评论都会受到赞赏。

Any suggestion or comment is appreciated.

推荐答案

要回答此问题,您需要做的只是阅读setJMSPriority方法的API文档,并告诉您原因。这是相关的文本。

To answer this question all you need to do is read the API docs for the setJMSPriority method and it tells you why. Here's the relevant text.


设置此消息的优先级。

Sets the priority level for this message.

发送消息时,JMS提供程序设置此字段。此方法可用于更改已接收消息的值。

JMS providers set this field when a message is sent. This method can be used to change the value for a message that has been received.

JMS提供程序(ActiveMQ,HornetMQ等)将生产者在发送时的优先级设置为默认值4,或者将其设置为您设置的生产者要使用的任何值,因此在发送消息本身之前设置该值不会产生任何作用。

The JMS Provider (ActiveMQ, HornetMQ, etc) set the priority in the producer on send to either the default value of 4, or to whatever value you've set the producer to use, so setting the value before send on the message itself won't have any effect.

这篇关于JMS消息优先级不适用于消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆