我正在使用 Node js stomp 库( https://github.com/gdaws/node-stomp )通过 stomp 从 activemq 发送接收消息。
问题:- 有一种情况我想安排在 n 分钟后发送消息。我没有看到任何方法可以使用此库(或任何其他 Nodejs 库)设置此 AMQ_SCHEDULED_DELAY header
有人使用这些消息属性进行调度吗?
最佳答案
计划消息值直接映射到同名的字符串值,因此 AMQ_SCHEDULED_DELAY 常量映射到消息属性中的“AMQ_SCHEDULED_DELAY”。这意味着在 STOMP 中安排消息很简单。
这里是 ActiveMQ 的示例单元测试。
@Test
public void testSendMessageWithDelay() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
String frame = "CONNECT\n" + "login:system\n" + "passcode:manager\n\n" + Stomp.NULL;
stompConnection.sendFrame(frame);
frame = stompConnection.receiveFrame();
assertTrue(frame.startsWith("CONNECTED"));
frame = "SEND\n" + "AMQ_SCHEDULED_DELAY:2000\n" + "destination:/queue/" + getQueueName() + "\n\n" + "Hello World" + Stomp.NULL;
stompConnection.sendFrame(frame);
TextMessage message = (TextMessage)consumer.receive(1000);
assertNull(message);
message = (TextMessage)consumer.receive(2500);
assertNotNull(message);
}
关于node.js - 如何使用 Stomp 延迟 activemq 消息 (AMQ_SCHEDULED_DELAY),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30064445/