java使用ProducerTemplate设置activemq优先级
有可能做到这一点吗
我正在尝试使用以下命令发送到队列:
producerTemplate.sendBodyAndProperty("activemq:queue.queue", message, "JMSPriority", priority);
我已将JMS配置设置为:
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>
然而,当我使用producertemplate发送消息时,activemq中显示的优先级为0:
即使当我正常发送消息(producerTemplate.sendBodyAndProperty("activemq:queue.queue", message)
)时,优先级显示为4
# 1 楼答案
JMSPriority
应该是头,而不是属性