Skip to content

Commit

Permalink
Update producer.ex
Browse files Browse the repository at this point in the history
  • Loading branch information
pkgodara committed Mar 10, 2025
1 parent 3dc8951 commit 5bb1161
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions lib/broadway_rabbitmq/producer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -687,21 +687,22 @@ defmodule BroadwayRabbitMQ.Producer do
init_client!(client, opts)
end

with {:ok, channel} <- client.setup_channel(config) do
# We monitor the channel but link to the connection (in the client, not here).
channel_ref = Process.monitor(channel.pid)
backoff = backoff && Backoff.reset(backoff)
{:ok, consumer_tag} = client.consume(channel, config)

%{
state
| channel: channel,
config: config,
consumer_tag: consumer_tag,
backoff: backoff,
channel_ref: channel_ref
}
else
case client.setup_channel(config) do
{:ok, channel} ->
# We monitor the channel but link to the connection (in the client, not here).
channel_ref = Process.monitor(channel.pid)
backoff = backoff && Backoff.reset(backoff)
{:ok, consumer_tag} = client.consume(channel, config)

%{
state
| channel: channel,
config: config,
consumer_tag: consumer_tag,
backoff: backoff,
channel_ref: channel_ref
}

{:error, reason} ->
handle_connection_failure(state, reason)
end
Expand Down

0 comments on commit 5bb1161

Please sign in to comment.