Skip to content

Commit 2008058

Browse files
dcorbachomichaelklishin
authored andcommitted
rabbitmq_shovel: detach link when closing amqp10 connections
When using an autodelete shovel, acks to source might still be in-flight when the connections start to close. Let's detach the link first to ensure all acks are processed.
1 parent daf1574 commit 2008058

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

deps/rabbitmq_shovel/src/rabbit_amqp10_shovel.erl

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -414,16 +414,21 @@ handle_dest(_Msg, _State) ->
414414
not_handled.
415415

416416
close_source(#{source := #{current := #{conn := Conn,
417-
session := Sess}}}) ->
418-
_ = amqp10_client:end_session(Sess),
419-
_ = amqp10_client:close_connection(Conn),
417+
session := Sess,
418+
link := LinkRef}}}) ->
419+
connection_close(Conn, Sess, LinkRef),
420420
ok;
421421
close_source(_Config) -> ok.
422422

423-
close_dest(#{dest := #{current := #{conn := Conn,
424-
session := Sess}}}) ->
423+
connection_close(Conn, Sess, LinkRef) ->
424+
_ = amqp10_client:detach_link(LinkRef),
425425
_ = amqp10_client:end_session(Sess),
426-
_ = amqp10_client:close_connection(Conn),
426+
_ = amqp10_client:close_connection(Conn).
427+
428+
close_dest(#{dest := #{current := #{conn := Conn,
429+
session := Sess,
430+
link := LinkRef}}}) ->
431+
connection_close(Conn, Sess, LinkRef),
427432
ok;
428433
close_dest(_Config) -> ok.
429434

0 commit comments

Comments
 (0)