可以这样做吗?
我正在尝试使用以下命令发送到队列:
producerTemplate.sendBodyAndProperty("activemq:queue.queue", message, "JMSPriority", priority);
我已经设置了 JMSConfiguration:
JmsConfiguration jmsConfiguration = new JmsConfiguration(pooledConnectionFactory);
jmsConfiguration.setDeliveryPersistent(false); // do not store a copy of the messages on the queue
jmsConfiguration.setPreserveMessageQos(true);
jmsConfiguration.setExplicitQosEnabled(true);
我还在 activemq.xml
中启用了排队:
<policyEntry queue=">" prioritizedMessages="true" useCache="false" expireMessagesPeriod="0" queuePrefetch="1" >
</policyEntry>
但是,当我使用生产者模板发送消息时,它在 activemq 中显示的优先级是 0:
即使当我正常发送消息时( ProducerTemplate.sendBodyAndProperty(“activemq:queue.queue”,message)
),优先级显示为4。
最佳答案
JMSPriority
应该是 header 而不是属性。
producerTemplate.sendBodyAndHeader("activemq:queue.queue", message, "JMSPriority", priority);
关于java - 使用 ProducerTemplate 设置 activemq 优先级,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27138036/