View Source RabbitMQStream.Consumer.FlowControl.MessageCount (rabbitmq_stream v0.4.0)

Message Count Strategy

Adds credits after the amount of consumed credit reaches a certain threshold.

Usage

defmodule MyApp.MyConsumer do
  alias RabbitMQStream.Consumer.FlowControl

  use RabbitMQStream.Consumer,
    offset_tracking: [FlowControl.MessageCount, credit_after: {:count, 1}]

  @impl true
  def handle_message(_message) do
    :ok
  end
end

Parameters

  • credit_after - The type of computation performed to decide whether to add more credit. Can be one of:
    • {:count, amount} - adds the amount in credits after the specified is consumed
    • {:ratio, ratio} - credits the missing amount after the ratio of remaining credits reaches the threshold

Defaults to {:count, 1}.