需要写jmsTemplate.setExplicitQosEnabled(true);
@Bean
public JmsTemplate jmsTemplate(ActiveMQConnectionFactory connectionFactory) {
JmsTemplate jmsTemplate = new JmsTemplate();
jmsTemplate.setConnectionFactory(connectionFactory);
//deliveryMode, priority, timeToLive 的开关,要生效,必须配置为true,默认false
jmsTemplate.setExplicitQosEnabled(true);
// 持久化消息
jmsTemplate.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
// 是否开启事务
jmsTemplate.setSessionTransacted(false);
// 消费者receive消息后必须手动的调用acknowledge()方法进行签收
jmsTemplate.setSessionAcknowledgeMode(Session.CLIENT_ACKNOWLEDGE);
return jmsTemplate;
}