View Source Broadway.Acknowledger behaviour (Broadway v1.0.7)

A behaviour used to acknowledge that the received messages were successfully processed or failed.

When implementing a new connector for Broadway, you should implement this behaviour and consider how the technology you're working with handles message acknowledgement.

The ack/3 callback must be implemented in order to notify the origin of the data that a message can be safely removed after been successfully processed and published. In case of failed messages or messages without acknowledgement, depending on the technology chosen, the messages can be either moved back in the queue or, alternatively, moved to a dead-letter queue.

Link to this section Summary

Callbacks

Invoked to acknowledge successful and failed messages.

Configures the acknowledger with new options.

Link to this section Callbacks

Link to this callback

ack(ack_ref, successful, failed)

View Source
@callback ack(
  ack_ref :: term(),
  successful :: [Broadway.Message.t()],
  failed :: [Broadway.Message.t()]
) ::
  :ok

Invoked to acknowledge successful and failed messages.

  • ack_ref is a term that uniquely identifies how messages should be grouped and sent for acknowledgement. Imagine you have a scenario where messages are coming from different producers. Broadway will use this information to correctly identify the acknowledger and pass it among with the messages so you can properly communicate with the source of the data for acknowledgement. ack_ref is part of Broadway.Message.acknowledger/0.

  • successful is the list of messages that were successfully processed and published.

  • failed is the list of messages that, for some reason, could not be processed or published.

Link to this callback

configure(ack_ref, ack_data, options)

View Source (optional)
@callback configure(ack_ref :: term(), ack_data :: term(), options :: keyword()) ::
  {:ok, new_ack_data :: term()}

Configures the acknowledger with new options.

Every acknowledger can decide how to incorporate the given options into its ack_data. The ack_data is the current acknowledger's data. The return value of this function is {:ok, new_ack_data} where new_ack_data is the updated data for the acknowledger.

Note that options are different for every acknowledger, as the acknowledger is what specifies what are the supported options. Check the documentation for the acknowledger you're using to see the supported options.

ack_ref and ack_data are part of Broadway.Message.acknowledger/0.