Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
whatyouhide authored Oct 6, 2024
1 parent aefed74 commit 955ab22
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/broadway_rabbitmq/producer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -378,15 +378,15 @@ defmodule BroadwayRabbitMQ.Producer do
Dead-letter exchanges are normal RabbitMQ exchanges designated for receiving messages
that have been rejected elsewhere. You can reference a dead-letter exchange when
defining a queue by supplying an `"x-dead-letter-exchange"` argument and optionally an
defining a queue by supplying a `"x-dead-letter-exchange"` argument and optionally a
`"x-dead-letter-routing-key"`. When a queue has a dead-letter exchange defined, then
failing a message with `Broadway.failed/2` or raising an exception in `Broadway.handle_message/3`
failing a message with `Broadway.Message.failed/2` or raising an exception in `c:Broadway.handle_message/3`
causes the message to be republished to the exchange named in the `"x-dead-letter-exchange"`
argument. The message's original routing key is kept unless the `"x-dead-letter-routing-key"`
argument specifies an override.
A bit more care is needed during setup when using dead-letter exchanges because the dead-letter
exchange must be declared and exist _before_ you attempt to reference it when declaring a queue.
exchange must be declared and exist *before* you attempt to reference it when declaring a queue.
For this reason, you may need to take additional steps when setting up your RabbitMQ instance
beyond what is available to you in the `:after_connect` option.
Expand Down Expand Up @@ -414,7 +414,6 @@ defmodule BroadwayRabbitMQ.Producer do
:ok = AMQP.Queue.bind(channel, "my_queue", "my_exchange", [])
Once you have your exchanges and queues established, you can start Broadway pipelines
to consume messages in the queues. For a thorough example, we need one pipeline which
will fail messages and another pipeline to consume messages from the dead-letter exchange.
Expand Down Expand Up @@ -479,17 +478,17 @@ defmodule BroadwayRabbitMQ.Producer do
end
To test out the dead-letter republishing behavior, try publishing a message into your
primary exchange and observe that it gets republished and consumed by the queue in the
dead-letter exchange, e.g.
dead-letter exchange:
iex> {:ok, connection} = AMQP.Connection.open()
iex> {:ok, channel} = AMQP.Channel.open(connection)
iex> AMQP.Basic.publish(channel, "my_exchange", "my_queue", "Am I dead?")
:ok
[debug] Failing message; this should republish to the dead-letter exchange
[debug] Dead letter message received!
"""

use GenStage
Expand Down

0 comments on commit 955ab22

Please # to comment.