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

test_message(broadway, data, opts \\ [])

View Source


test_message(broadway :: atom(), term(), opts :: Keyword.t()) :: reference()

Sends a test message through the Broadway pipeline.

This is a convenience used for testing. The given data is automatically wrapped in a Broadway.Message with Broadway.CallerAcknowledger configured to send a message back to the caller once the message has been fully processed.

The message is set to be flushed immediately, without waiting for the Broadway pipeline batch_size to be filled or the batch_timeout to be triggered.

It returns a reference that can be used to identify the ack messages.

See "Testing" section in module documentation for more information.


  • :metadata - optionally a map of additional fields to add to the message. This can be used, for example, when testing BroadwayRabbitMQ.Producer.

  • :acknowledger - optionally a function that generates ack fields of Broadway.Message.t() that is sent. This function should have following spec (data :: term, {pid, reference()} -> {module, ack_ref :: term, data :: term}).


For example, in your tests, you may do:

ref = Broadway.test_message(broadway, 1)
assert_receive {:ack, ^ref, [successful], []}

or if you want to override which acknowledger shall be called, you may do:

acknowledger = fn data, ack_ref -> {MyAck, ack_ref, :ok} end
Broadway.test_message(broadway, 1, acknowledger: acknowledger)

Note that messages sent using this function will ignore demand and :transform option specified in :producer option in Broadway.start_link/2.