RabbitMQ + STOMP - 我可以在订阅上创建持久队列吗?

时间:2014-11-20 14:03:48

标签: queue rabbitmq stomp

我可以让RabbitMQ 3.4.1创建名为" q123"的新DURABLE队列当STOMP客户端发送

SUBSCRIBE
destination: /amq/queue/q123
...

并将此队列用于以后的订阅?

1 个答案:

答案 0 :(得分:2)

您无法在STOMP网关外部创建新队列。您可以SENDSUBSCRIBE,但不能创建新的。

如果您要在STOMP插件设置指定的vhost中引用/queue/<your-queue-name>(默认情况下它是标准/ vhost),STOMP可能会为您创建。

因此,这样的STOMP帧将在new-random-one vhost中创建/持久队列。

SUBSCRIBE
destination: /queue/new-random-one

以下是如何在原始shell上运行它(^ @代表Ctrl + @,空行之前很重要):

nc localhost 61613
CONNECT

^@
CONNECTED
session:session-3IE6yYjn6borQ_4KLfxLMw
heart-beat:0,0
server:RabbitMQ/3.4.1
version:1.0

SUBSCRIBE
destination: /queue/new-random-one

^@
DISCONNECT

^@

之后,即使断开连接,您也会看到new-random-one队列仍将驻留在默认虚拟主机中。

有关详情,请阅读Destinations手册页的RabbitMQ STOMP Adapter部分的详细信息。