diff --git a/lib/broadway_rabbitmq/producer.ex b/lib/broadway_rabbitmq/producer.ex index 346adbf..3dafee7 100644 --- a/lib/broadway_rabbitmq/producer.ex +++ b/lib/broadway_rabbitmq/producer.ex @@ -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