Skip to content

Commit 1ce75c7

Browse files
committed
handle different queue states on deletion from the mgmt API
1 parent 575045f commit 1ce75c7

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

deps/rabbit/src/amqqueue.erl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
is_amqqueue/1,
7474
is_auto_delete/1,
7575
is_durable/1,
76+
is_exclusive/1,
7677
is_classic/1,
7778
is_quorum/1,
7879
pattern_match_all/0,
@@ -557,6 +558,11 @@ is_auto_delete(#amqqueue{auto_delete = AutoDelete}) ->
557558

558559
is_durable(#amqqueue{durable = Durable}) -> Durable.
559560

561+
-spec is_exclusive(amqqueue()) -> boolean().
562+
563+
is_exclusive(Queue) ->
564+
is_pid(get_exclusive_owner(Queue)).
565+
560566
-spec is_classic(amqqueue()) -> boolean().
561567

562568
is_classic(Queue) ->

deps/rabbitmq_management/src/rabbit_mgmt_wm_queue.erl

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,13 @@ delete_resource(ReqData, Context = #context{user = #user{username = ActingUser}}
8181
Name = rabbit_misc:r(VHost, queue, QName),
8282
case rabbit_amqqueue:lookup(Name) of
8383
{ok, Q} ->
84-
case rabbit_amqqueue:delete(Q, IfUnused, IfEmpty, ActingUser) of
84+
IsExclusive = amqqueue:is_exclusive(Q),
85+
ExclusiveOwnerPid = amqqueue:get_exclusive_owner(Q),
86+
try rabbit_amqqueue:delete_with(Q, ExclusiveOwnerPid, IfUnused, IfEmpty, ActingUser, IsExclusive) of
8587
{ok, _} ->
86-
{true, ReqData, Context};
87-
{error, not_empty} ->
88-
Explanation = io_lib:format("~ts not empty", [rabbit_misc:rs(Name)]),
89-
rabbit_log:warning("Delete queue error: ~ts", [Explanation]),
90-
rabbit_mgmt_util:bad_request(list_to_binary(Explanation), ReqData, Context);
91-
{error, in_use} ->
92-
Explanation = io_lib:format("~ts in use", [rabbit_misc:rs(Name)]),
88+
{true, ReqData, Context}
89+
catch
90+
_:#amqp_error{explanation = Explanation} ->
9391
rabbit_log:warning("Delete queue error: ~ts", [Explanation]),
9492
rabbit_mgmt_util:bad_request(list_to_binary(Explanation), ReqData, Context)
9593
end;

0 commit comments

Comments
 (0)