Broadway.handle_failed

You're seeing just the callback handle_failed, go back to Broadway module for more information.
Link to this callback

handle_failed(messages, context)

View Source (optional) (since 0.5.0)

Specs

handle_failed(messages :: [Broadway.Message.t()], context :: term()) :: [
  Broadway.Message.t()
]

Invoked for failed messages (if defined).

It expects:

  • messages is the list of messages that failed. If a message is failed in handle_message/3, this will be a list with a single message in it. If some messages are failed in handle_batch/4, this will be the list of failed messages.

  • context is the user-defined data structure passed to start_link/2.

This callback must return the same messages given to it, possibly updated. For example, you could update the message data or use Broadway.Message.configure_ack/2 in a centralized place to configure how to ack the message based on the failure reason.

This callback is optional. If present, it's called before the messages are acknowledged according to the producer. This gives you a chance to do something with the message before it's acknowledged, such as storing it in an external persistence layer or similar.

This callback is also invoked if handle_message/3 or handle_batch/4 crash or raise an error. If this callback crashes or raises an error, the messages are failed internally by Broadway to avoid crashing the process.