Implement handle_failed/3
Learn to handle failed messages through the handle_message callback function.
The handle_failed/3
callback function
Right now, when we return a message from handle_message/3
, Broadway
automatically acknowledges it since it reaches the end of the pipeline.
However, if an unhandled exception happens in our business logic, the message is marked as failed. We can also manually mark a message as failed using Broadway.Message.failed/2
. This could be useful when we want to discard messages we don’t want to process.
Remember that in @producer_config
we configure the :on_failure
setting with the :reject_and_requeue
value. This means that failed messages will be sent back to RabbitMQ and ...