Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify documentation for :on_success and :on_failure #73

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions lib/broadway_rabbitmq/producer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,22 @@ defmodule BroadwayRabbitMQ.Producer do
* `:ack` - acknowledge the message. RabbitMQ will mark the message as acked and
will not redeliver it to any other consumer.

* `:reject` - rejects the message without requeuing (basically, discards the message).
RabbitMQ will not redeliver the message to any other consumer.
* `:reject` - rejects the message without requeuing (basically, discards
the message). RabbitMQ will not redeliver the message to any other
consumer, but a queue can be configured to send rejected messages to a
[dead letter exchange](https://www.rabbitmq.com/dlx.html), where another
consumer can see why it was dead lettered, how many times, etc, and
potentially republish it.

* `:reject_and_requeue` - rejects the message and tells RabbitMQ to requeue it so
that it can be delivered to a consumer again. `:reject_and_requeue` always
requeues the message.
that it can be delivered to a consumer again. `:reject_and_requeue`
always requeues the message. If the message is unprocessable, this will
cause an infinite loop of retries.
Copy link
Contributor Author

@nathanl nathanl Sep 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The infinite loop of retries bit us in production, which is why I think this clarification is important.

I would like to suggest that, rather than defaulting to :reject_and_requeue, the user be required to specify one of these options. This would prompt them to consider the tradeoffs.


* `:reject_and_requeue_once` - rejects the message and tells RabbitMQ to requeue it
the first time. If a message was already requeued and redelivered, it will be
rejected and not requeued again.
rejected and not requeued again. This feature uses Broadway-specific message metadata,
not RabbitMQ's dead lettering feature.

## Metadata

Expand Down