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

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

Functions

ACK message consumption

Creates a consumer from configuration

Find consumer by consumer_tag

Callbacks

Consumer acknowledgements enabled

Consumer message prefetch count

Queue to consume from

Link to this section Types

Specs

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)

Specs

consumer_tag() :: String.t()

Consumer Tag

Specs

prefetch_count() :: integer()

Consumer Prefetch

Specs

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 Functions

Link to this function

ack_message(map, delivery_tag)

View Source

Specs

ack_message(t(), integer()) :: :ok | {:error, term()}

ACK message consumption

Link to this function

create(connection, config)

View Source

Specs

create(AMQP.Connection.t(), config()) :: t()

Creates a consumer from configuration

Link to this function

get(consumers, consumer_tag)

View Source

Specs

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

Specs

reject_message(t(), integer(), boolean()) :: :ok | {:error, term()}

Reject message

Link to this section Callbacks

Specs

ack(consumer :: t()) :: boolean()

Consumer acknowledgements enabled

Link to this callback

prefetch_count(consumer)

View Source

Specs

prefetch_count(consumer :: t()) :: prefetch_count()

Consumer message prefetch count

Specs

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

Queue to consume from