Skip to content

Commit b753442

Browse files
author
Daniil Fedotov
committed
Raise a protocol error when declaring a queue on a stopped vhost
1 parent 1834609 commit b753442

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/rabbit_amqqueue.erl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -339,11 +339,17 @@ declare(QueueName = #resource{virtual_host = VHost}, Durable, AutoDelete, Args,
339339
{ok, Node0} -> Node0;
340340
{error, _} -> Node
341341
end,
342-
343342
Node1 = rabbit_mirror_queue_misc:initial_queue_node(Q, Node1),
344-
gen_server2:call(
345-
rabbit_amqqueue_sup_sup:start_queue_process(Node1, Q, declare),
346-
{init, new}, infinity).
343+
case rabbit_vhost_sup_sup:get_vhost_sup(VHost, Node1) of
344+
{ok, _} ->
345+
gen_server2:call(
346+
rabbit_amqqueue_sup_sup:start_queue_process(Node1, Q, declare),
347+
{init, new}, infinity);
348+
{error, Error} ->
349+
rabbit_misc:protocol_error(internal_error,
350+
"Cannot declare a queue '~s' on node '~s': ~255p",
351+
[rabbit_misc:rs(QueueName), Node1, Error])
352+
end.
347353

348354
internal_declare(Q, true) ->
349355
rabbit_misc:execute_mnesia_tx_with_tail(

0 commit comments

Comments
 (0)