Mississippi.Consumer.MessageTracker behaviour (Mississippi v1.0.0)

View Source

The MessageTracker process guarantees that messages sharing the same sharding key are processed in (chronological) order. Under the hood, messages are put in a FIFO queue, and the next message is processed only if the current one has been handled (either acked or rejected). In order to maintain the strong ordering guarantee, it is possible that in some corner cases a message gets processed twice, but after all with strange aeons, even death may die.

Summary

Functions

Signals to the MessageTracker process to ack the message. This call is blocking, as only first in-order message can be acked.

Provides a reference to the MessageTracker process that will track the set of messages identified by the given sharding key.

Starts handling a message. This call is not blocking. The message will be put in the MessageTracker process FIFO queue, and processed when it is on top of it.

Signals to the MessageTracker process to reject the message. This call is blocking, as only first in-order message can be rejected.

Callbacks

get_message_tracker(sharding_key)

@callback get_message_tracker(sharding_key :: term()) ::
  {:ok, pid()} | {:error, :message_tracker_start_fail}

Functions

ack_delivery(message_tracker, message)

Signals to the MessageTracker process to ack the message. This call is blocking, as only first in-order message can be acked.

get_message_tracker(sharding_key)

@spec get_message_tracker(sharding_key :: term()) ::
  {:ok, pid()} | {:error, :message_tracker_start_fail}

Provides a reference to the MessageTracker process that will track the set of messages identified by the given sharding key.

handle_message(message_tracker, message, channel)

Starts handling a message. This call is not blocking. The message will be put in the MessageTracker process FIFO queue, and processed when it is on top of it.

reject(message_tracker, message)

Signals to the MessageTracker process to reject the message. This call is blocking, as only first in-order message can be rejected.