简体   繁体   English

RabbiMQ踩踏自动删除队列-前提条件失败

[英]RabbiMQ stomp auto delete queue - Precondition failed

I am writing application that uses STOMP for communication. 我正在编写使用STOMP进行通信的应用程序。 Server side is written using Spring Boot 2.1.7 and as external broker RabbitMQ 3.7.1 is used. 服务器端是使用Spring Boot 2.1.7编写的,并且作为外部代理使用RabbitMQ 3.7.1。 On client side, I am using StompJS. 在客户端,我正在使用StompJS。

When client subscribes to user destination, eg. 当客户端订阅用户目的地时,例如 /user/queue/some-queue Spring will map it to /queue/some-queue-{sessionID} and RabbitMQ creates queue with corresponding name. /user/queue/some-queue Spring将其映射到/queue/some-queue-{sessionID} ,RabbitMQ创建具有相应名称的队列。

On subscription I added header {'auto-delete': true} , as specified here RabbitMQ Stomp Docs , and that created auto delete queue in RabbitMQ. 在订阅时,我添加了标头{'auto-delete': true} (如此处RabbitMQ Stomp Docs所示) ,并在RabbitMQ中创建了自动删除队列。

Problem comes when I try sending message to user as 当我尝试向用户发送消息时出现问题

simpTemplate.convertAndSendToUser('user', '/queue/some-queue', message)

Spring correctly translated queue name, but rabbitmq responds with error Spring正确翻译了队列名称,但是rabbitmq响应错误

PRECONDITION_FAILED - inequivalent arg 'auto_delete' for queue

What can I do to fix this issue? 我该怎么做才能解决此问题?

I think I found a solution. 我想我找到了解决方案。 If I add same same headers, which were defined during subscription, when sending message, it will work correctly. 如果我添加相同的标头,这些标头是在订阅期间定义的,则在发送消息时,它将正常工作。

On example it looks like this: 在示例中,它看起来像这样:

Map<String, Object> headers = new HashMap<>();
headers.put("auto-delete", "true");
simpMessagingTemplate.convertAndSendToUser("some-user", "/queue/some-queue", "Test payload", headers);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM