Skip to content

Commit 1e17017

Browse files
Merge pull request #8697 from rabbitmq/rabbitmq-server-8692
Gracefully close shovel if destination exchange does not exist (#8692 with some cosmetic changes)
2 parents fbe79ff + af63d6b commit 1e17017

File tree

3 files changed

+35
-4
lines changed

3 files changed

+35
-4
lines changed

deps/rabbitmq_shovel/src/rabbit_amqp091_shovel.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ handle_source({'EXIT', Conn, Reason},
263263
#{source := #{current := {Conn, _, _}}}) ->
264264
{stop, {inbound_conn_died, Reason}};
265265

266-
handle_source({'EXIT', _Pid, {shutdown, {server_initiated_close, ?PRECONDITION_FAILED, Reason}}}, _State) ->
266+
handle_source({'EXIT', _Pid, {shutdown, {server_initiated_close, _, Reason}}}, _State) ->
267267
{stop, {inbound_link_or_channel_closure, Reason}};
268268

269269
handle_source(_Msg, _State) ->
@@ -288,7 +288,7 @@ handle_dest(#'basic.cancel'{}, #{name := Name}) ->
288288
handle_dest({'EXIT', Conn, Reason}, #{dest := #{current := {Conn, _, _}}}) ->
289289
{stop, {outbound_conn_died, Reason}};
290290

291-
handle_dest({'EXIT', _Pid, {shutdown, {server_initiated_close, ?PRECONDITION_FAILED, Reason}}}, _State) ->
291+
handle_dest({'EXIT', _Pid, {shutdown, {server_initiated_close, _, Reason}}}, _State) ->
292292
{stop, {outbound_link_or_channel_closure, Reason}};
293293

294294
handle_dest(#'connection.blocked'{}, State) ->

deps/rabbitmq_shovel/src/rabbit_amqp10_shovel.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ handle_source({'EXIT', Conn, Reason},
202202
#{source := #{current := #{conn := Conn}}}) ->
203203
{stop, {outbound_conn_died, Reason}};
204204

205-
handle_source({'EXIT', _Pid, {shutdown, {server_initiated_close, ?PRECONDITION_FAILED, Reason}}}, _State) ->
205+
handle_source({'EXIT', _Pid, {shutdown, {server_initiated_close, _, Reason}}}, _State) ->
206206
{stop, {inbound_link_or_channel_closure, Reason}};
207207

208208
handle_source(_Msg, _State) ->
@@ -260,7 +260,7 @@ handle_dest({'EXIT', Conn, Reason},
260260
#{dest := #{current := #{conn := Conn}}}) ->
261261
{stop, {outbound_conn_died, Reason}};
262262

263-
handle_dest({'EXIT', _Pid, {shutdown, {server_initiated_close, ?PRECONDITION_FAILED, Reason}}}, _State) ->
263+
handle_dest({'EXIT', _Pid, {shutdown, {server_initiated_close, _, Reason}}}, _State) ->
264264
{stop, {outbound_link_or_channel_closure, Reason}};
265265

266266
handle_dest(_Msg, _State) ->

deps/rabbitmq_shovel/test/dynamic_SUITE.erl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ groups() ->
3131
set_empty_properties_using_map,
3232
headers,
3333
exchange,
34+
missing_dest_exchange,
3435
restart,
3536
change_definition,
3637
autodelete,
@@ -262,6 +263,36 @@ exchange(Config) ->
262263
<<"queue">>, <<"hello">>)
263264
end).
264265

266+
267+
missing_dest_exchange(Config) ->
268+
with_ch(Config,
269+
fun (Ch) ->
270+
amqp_channel:call(
271+
Ch, #'queue.declare'{queue = <<"src">>,
272+
durable = true}),
273+
amqp_channel:call(
274+
Ch, #'queue.declare'{queue = <<"dest">>,
275+
durable = true}),
276+
amqp_channel:call(
277+
Ch, #'queue.bind'{queue = <<"src">>,
278+
exchange = <<"amq.direct">>,
279+
routing_key = <<"src-key">>}),
280+
shovel_test_utils:set_param(Config,
281+
<<"test">>, [{<<"src-queue">>, <<"src">>},
282+
{<<"dest-exchange">>, <<"dest-ex">>},
283+
{<<"dest-exchange-key">>, <<"dest-key">>},
284+
{<<"src-prefetch-count">>, 1}]),
285+
publish(Ch, <<"amq.direct">>, <<"src-key">>, <<"hello">>),
286+
expect_empty(Ch, <<"src">>),
287+
amqp_channel:call(
288+
Ch, #'exchange.declare'{exchange = <<"dest-ex">>}),
289+
amqp_channel:call(
290+
Ch, #'queue.bind'{queue = <<"dest">>,
291+
exchange = <<"dest-ex">>,
292+
routing_key = <<"dest-key">>}),
293+
publish_expect(Ch, <<"amq.direct">>, <<"src-key">>, <<"dest">>, <<"hello!">>)
294+
end).
295+
265296
restart(Config) ->
266297
with_ch(Config,
267298
fun (Ch) ->

0 commit comments

Comments
 (0)