How to delete exlusive queue

543 views
Skip to first unread message

qplc

unread,
Oct 29, 2018, 9:59:26 AM10/29/18
to rabbitmq-users
Hi,

I need a help to delete exclusive queue explicitly trough Java application.
I can see the binding available but consumer down.
rabbitmqctl list_bindings | grep "amq.gen-test"
    exchange    amq.gen-test   queue    amq.gen-test   []
auto.exchange    exchange    amq.gen-test    queue        []

rabbitmqctl list_queues name auto_delete exclusive consumers messages | grep "amq.gen-test"
amq.gen-test    false    true     0    3567

Why the queue is not deleted.
I'm getting following errors whenever I'm deleting it excplicitly.
error: com.rabbitmq.client.AlreadyClosedException: channel is already closed due to channel error; protocol method: #method<channel.close>(reply-code=405, reply-text=RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'amq.gen-test==' in vhost '/', class-id=50, method-id=50)

Thanks in advance.

Michael Klishin

unread,
Oct 29, 2018, 3:23:33 PM10/29/18
to rabbitm...@googlegroups.com
Close its connection or let the connection that declared it delete it [1].

Other connections by definition cannot do anything with an exclusive queue, and attempts to do so result
in a channel-level protocol exception that renders that channel closed.


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ

qplc

unread,
Oct 29, 2018, 3:29:24 PM10/29/18
to rabbitmq-users
Thanks Michael for your reply.
Can you also help me to find the connection and to know how do I delete the connection as application used to create the specific exclusive queue is no more connected to the RMQ nodes. I've restarted the application and it has created other exclusive queues.

Michael Klishin

unread,
Oct 29, 2018, 3:38:41 PM10/29/18
to rabbitm...@googlegroups.com
I believe there is a link to the owner connection on the queue page in management UI.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

qplc

unread,
Oct 29, 2018, 3:43:09 PM10/29/18
to rabbitmq-users
Found RMQ node3 is the owner of the queue as seen on the management UI.
But, whenever I'm trying to delete it from the UI it is giving me following error.
405 RESOURCE_LOCKED - cannot obtain exclusive access to locked queue 'amq.gen-test' in vhost '/'


On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

Michael Klishin

unread,
Oct 29, 2018, 3:57:15 PM10/29/18
to rabbitm...@googlegroups.com
Yeah apparently there seems to be no easy way to find out the name of the owner connection.

If you know what application declares them, what are you looking to do? If it's just delete the queue then
[1] might be a drastic but helpful measure. But when the app restarts it will just declare more exclusive queues.
Shouldn't the app be investigated, updated and redeployed?


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

qplc

unread,
Oct 29, 2018, 4:03:51 PM10/29/18
to rabbitmq-users
Actually, we have already tried the rolling restart of the application. But, seems it is not helpful.
However, exclusive queues should be deleted whenever consumer goes down. For this specific queue I can see no consumer is up. What could be causing this. Why the exclusive queue did't get delete?

On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

Michael Klishin

unread,
Oct 29, 2018, 4:09:38 PM10/29/18
to rabbitm...@googlegroups.com
Exclusive queues are deleted when their declaring connection is closed (or lost and that is *detected* [1]).
It's auto-delete queues that are deleted when the last consumer is unbound (if there ever was one).


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

qplc

unread,
Oct 29, 2018, 4:36:23 PM10/29/18
to rabbitmq-users
Thanks Michael for all your help.
I'll try to detect the error connection and forcefully close it.

On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

qplc

unread,
Oct 30, 2018, 12:15:57 AM10/30/18
to rabbitmq-users
Hi Michael,

I tried to track the connection but couldn't find it on management UI. I can see the queue owner is node3 but none of our application connection is seen to node.
Is there any other way to fix this. The queue size is increasing gradually.

On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

Michael Klishin

unread,
Oct 30, 2018, 7:16:32 AM10/30/18
to rabbitm...@googlegroups.com
There is `rabbitmqctl delete_queue` and [1].


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

qplc

unread,
Oct 30, 2018, 12:30:46 PM10/30/18
to rabbitmq-users
Even 'rabbitmqctl delete_queue' isn't working. Since the connection has been dropped but the exclusive queue has stayed back we can't even use forceful connection delete option. Would rabbitmqadmin work in this case?


On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

Michael Klishin

unread,
Oct 30, 2018, 1:06:39 PM10/30/18
to rabbitm...@googlegroups.com
See the link above. It uses an internal API that bypasses all exclusivity checks.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Oct 30, 2018, 1:06:43 PM10/30/18
to rabbitm...@googlegroups.com
rabbitmqadmin uses the same API as management UI.

qplc

unread,
Oct 30, 2018, 1:22:21 PM10/30/18
to rabbitmq-users
Yes, I tried as seen in the link but got syntax error.

rabbitmqctl eval 'rabbit_amqqueue:internal_delete({resource,<<"/">>,amq.gen-test,<<"username">>}, <<"password">>).'

Error: syntax error before: '.'

Please correct.

On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

qplc

unread,
Oct 30, 2018, 1:24:32 PM10/30/18
to rabbitmq-users
Isn't it supported on RMQ server version 3.6.12?


On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:
Message has been deleted

qplc

unread,
Oct 30, 2018, 1:29:48 PM10/30/18
to rabbitmq-users
Issued below command:
rabbitmqctl eval 'rabbit_amqqueue:internal_delete({resource,<<"/">>,queue,<<"amq.gen-test">>}, <<"username">>).'

Getting below error:
Error: {undef,
           [{rabbit_amqqueue,internal_delete,
                [{resource,<<"/">>,queue,<<"amq.gen-test">>},
                 <<"username">>],
                []},
            {erl_eval,do_apply,6,[{file,"erl_eval.erl"},{line,670}]},
            {rpc,'-handle_call_call/6-fun-0-',5,
                [{file,"rpc.erl"},{line,197}]}]}


On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:

Michael Klishin

unread,
Oct 30, 2018, 1:37:13 PM10/30/18
to rabbitm...@googlegroups.com
In 3.6.x that function doesn't accept the username.

You can also try [1][2]. In 3.7.x those functions require one more parameter: an acting user.


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Michael Klishin

unread,
Oct 30, 2018, 1:38:15 PM10/30/18
to rabbitm...@googlegroups.com
Also, rabbitmqctl delete_queue isn't available in 3.6.x.

qplc

unread,
Oct 30, 2018, 1:46:34 PM10/30/18
to rabbitmq-users
Thanks a lot Michael. The exclusive queue got deleted by issuing below command.

Below command worked with RMQ server version: 3.6.12.

rabbitmqctl eval 'Q = {resource, <<"/">>, queue, <<"amq.gen-test">>}, rabbit_amqqueue:internal_delete(Q).'


On Monday, October 29, 2018 at 7:29:26 PM UTC+5:30, qplc wrote:
Reply all
Reply to author
Forward
0 new messages