View Source Lapin.Consumer behaviour (lapin v1.0.5)

Extensible behaviour to define consumer configuration.

Lapin provides a number of submodules which implement the patterns found in the RabbitMQ Tutorials.

defmodule ExampleApp.SomeConsumer do
  use Lapin.Consumer

  [... callbacks implementation ...]
end

Link to this section Summary

Types

Consumer configuration

Consumer Tag

Consumer Prefetch

t()

Lapin Consumer Behaviour

Callbacks

Consumer acknowledgements enabled

Consumer message prefetch count

Queue to consume from

Functions

ACK message consumption

Creates a consumer from configuration

Find consumer by consumer_tag

Link to this section Types

@type config() :: Keyword.t()

Consumer configuration

The following keys are supported:

If using the Lapin.Consumer.Config default implementation, the following keys are also supported:

  • queue: queue to consume from, (String.t(), required)
  • ack: producer ack (boolean(), default: false*
  • prefetch_count: consumer prefetch count (integer(), default: 1)
@type consumer_tag() :: String.t()

Consumer Tag

@type prefetch_count() :: integer()

Consumer Prefetch

@type t() :: %Lapin.Consumer{
  channel: AMQP.Channel.t(),
  config: config(),
  consumer_tag: consumer_tag(),
  pattern: atom(),
  queue: String.t()
}

Lapin Consumer Behaviour

Link to this section Callbacks

@callback ack(consumer :: t()) :: boolean()

Consumer acknowledgements enabled

Link to this callback

prefetch_count(consumer)

View Source
@callback prefetch_count(consumer :: t()) :: prefetch_count()

Consumer message prefetch count

@callback queue(consumer :: t()) :: Lapin.Queue.t()

Queue to consume from

Link to this section Functions

Link to this function

ack_message(map, delivery_tag)

View Source
@spec ack_message(t(), integer()) :: :ok | {:error, term()}

ACK message consumption

Link to this function

create(connection, config)

View Source
@spec create(AMQP.Connection.t(), config()) :: t()

Creates a consumer from configuration

Link to this function

get(consumers, consumer_tag)

View Source
@spec get([t()], consumer_tag()) :: {:ok, t()} | {:error, :not_found}

Find consumer by consumer_tag

Link to this function

reject_message(map, delivery_tag, requeue)

View Source
@spec reject_message(t(), integer(), boolean()) :: :ok | {:error, term()}

Reject message