如何通过Stomp.js设置回复主题

时间:2014-08-11 06:51:17

标签: c# javascript jms activemq stomp

在使用NMS API的C#中,我们以这种方式为ActiveMQ设置响应主题

IDestination temp = session.CreateTemporaryTopic();
ITopic consumer = session.CreateConsumer(temp);

在发送消息时,我们将其设置为......

TextMessage reqMessage = session.CreateTextMessage(message);
reqMessage.NMSReplyTo = temp;

我们如何使用Stomp.js做同样的事情?

1 个答案:

答案 0 :(得分:1)

大多数STOMP操作都是使用放在您发送的Message中的特定标头完成的。在这种情况下,回复' header表示接收客户端应发送其响应的地址。因此,模式将是通过回复'发送消息。标头集,这样的东西取决于您使用的库:

stomp.subscribe("/temp-queue/response-queue")
stomp.publish("/queue/work-queue", "WORK", {"reply-to" => "/temp-queue/response-queue"})

由于您正在使用临时主题,因此必须确保在发送响应消息之前有订阅者,否则它将无法获得所有回复。

相关问题