【发布时间】:2021-12-26 11:21:46
【问题描述】:
我这里有一个 Artemis 的 bootstrap.xml 配置文件
<broker xmlns="http://activemq.org/schema" schedulerSupport="true">
<jaas-security domain="activemq"/>
<server configuration="file:/opt/activemq/apache-artemis-home/etc//broker.xml"/>
<web bind="http://10.0.34.96:8161" path="web">
<app url="activemq-branding" war="activemq-branding.war"/>
<app url="artemis-plugin" war="artemis-plugin.war"/>
<app url="console" war="console.war"/>
</web>
</broker>
即使 artemis 服务器重新启动,调度消息仍然不起作用。消费者立即从TEST队列中获取消息。
try {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://10.0.34.96:61616");
Connection connection = factory.createConnection();
connection.start();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create Destination queue
Destination queue = session.createQueue("TEST");
MessageProducer producer = session.createProducer(queue);
producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
long schedDelivery = System.currentTimeMillis() + 50000;
String msg = "Hello World (test SCHED_DELIVERY) "+schedDelivery;
TextMessage message = session.createTextMessage(msg);
// message.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, 100000);
message.setLongProperty("_HQ_SCHED_DELIVERY", schedDelivery);
System.out.println("Producer Sent: " + msg);
producer.send(message);
session.close();
connection.close();
}
catch (Exception ex) {
System.out.println("Exception Occured");
}
有人知道如何设置ScheduledMessage.AMQ_SCHEDULED_DELAY 或_HQ_SCHED_DELIVERY 属性吗?
【问题讨论】:
标签: java jms activemq-artemis