Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
Close channels explicitly
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorszun committed Nov 19, 2018
1 parent 5d545c5 commit 1a3a6fb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lib/consumer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,11 @@ defmodule GenRMQ.Consumer do

@doc false
@impl GenServer
def terminate(reason, %{module: module, conn: conn}) do
def terminate(reason, %{module: module, conn: conn, in: in_chan, out: out_chan}) do
Logger.debug("[#{module}]: Terminating consumer, reason: #{inspect(reason)}")
AMQP.Connection.close(conn)
Channel.close(in_chan)
Channel.close(out_chan)
Connection.close(conn)
end

##############################################################################
Expand Down
5 changes: 3 additions & 2 deletions lib/publisher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,10 @@ defmodule GenRMQ.Publisher do

@doc false
@impl GenServer
def terminate(reason, %{module: module, conn: conn}) do
def terminate(reason, %{module: module, conn: conn, channel: channel}) do
Logger.debug("[#{module}]: Terminating publisher, reason: #{inspect(reason)}")
AMQP.Connection.close(conn)
Channel.close(channel)
Connection.close(conn)
end

##############################################################################
Expand Down

0 comments on commit 1a3a6fb

Please sign in to comment.