RabbiMQ stomp auto delete queue - Precondition failed

407 views
Skip to first unread message

Boris Tuponja

unread,
Sep 7, 2019, 2:43:31 PM9/7/19
to rabbitmq-users
Greetings,

I wrote this question on stackoverflow (link), but I will repeat it here. 

I am writing application that uses STOMP for communication. Server side is written using Spring Boot 2.1.7 and as external broker RabbitMQ 3.7.1 is used. On client side, I am using StompJS.

When client subscribes to user destination, e.g. /user/queue/some-queue, Spring will map it to /queue/some-queue-user{sessionID}and RabbitMQ creates queue with name some-queue-user{sessionID}. That part is correct and works as expected.

On subscription I added header {'auto-delete': true}, as specified here in RabbitMQ Stomp Docs, and that created auto delete queue in RabbitMQ, which I can verify using manager plugin.

When I try to send something on that queue I receive error 

PRECONDITION_FAILED - inequivalent arg 'auto_delete' for queue 'some-queue-...


Am I doing something wrong here or did I misunderstood documentation for queue?

I created sample project that illustrates this issue (link). 

Thank you very much.

Best regards,
Boris Tuponja

Luke Bakken

unread,
Sep 8, 2019, 2:09:58 PM9/8/19
to rabbitmq-users
Hi Boris,

After you create a queue, you can't change that queue's properties. In this case, you're trying to change the queue to auto-delete.

The code that originally creates the queue must create it as an auto-delete queue, or subsequent declare operations must not declare it as auto-delete.

Thanks,
Luke

Boris Tuponja

unread,
Sep 9, 2019, 7:43:36 AM9/9/19
to rabbitmq-users
Hi Luke,

Thank you for the answer.
Unfortunately, I have not been clean enough in my explanation.
I am not trying to change queue properties. The queue is created on STOMP subscription to queue and headers control queue properties. So, on subscription I added header {'auto-delete': true} and correct queue is created. But when I try to send something to that queue, I receive the error.


Thanks.
Boris

Luke Bakken

unread,
Sep 9, 2019, 11:18:40 AM9/9/19
to rabbitmq-users
Hi Boris,

I see that you found a solution by adding the auto-delete header to your publishing code - https://stackoverflow.com/q/57826317

That is the solution I was going to propose. I'm investigating why it is necessary and will follow up here.

Thank you very much for providing code to reproduce the issue.

Luke

Luke Bakken

unread,
Sep 9, 2019, 11:56:34 AM9/9/19
to rabbitmq-users
Hi Boris,

Yes, it is required to add the auto-delete header when publishing messages.

This is due to the following code, which is part of sending a message - https://github.com/rabbitmq/rabbitmq-stomp/blob/master/src/rabbit_stomp_processor.erl#L753

The ensure_endpoint function declares the queue again to ensure it exists. Since the header is missing, the queue arguments are not the same and you see the precondition_failed message.

Thanks,
Luke


On Monday, September 9, 2019 at 8:18:40 AM UTC-7, Luke Bakken wrote:
Hi Boris,

Boris Tuponja

unread,
Sep 10, 2019, 2:43:09 AM9/10/19
to rabbitmq-users
Hi Luke,

Thank you very much for clarification and support.

Best regards,
Boris
Reply all
Reply to author
Forward
0 new messages