View Source Lapin.Consumer behaviour (lapin v2.0.0)
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
Summary
Functions
ACK message consumption
Creates a consumer from configuration
Find consumer by consumer_tag
Reject message
Types
@type config() :: Keyword.t()
Consumer configuration
The following keys are supported:
- pattern: producer pattern (module using the
Lapin.Producer
behaviour)
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
Callbacks
Consumer acknowledgements enabled
@callback prefetch_count(consumer :: t()) :: prefetch_count()
Consumer message prefetch count
@callback queue(consumer :: t()) :: Lapin.Queue.t()
Queue to consume from
Functions
ACK message consumption
@spec create(AMQP.Connection.t(), config()) :: t()
Creates a consumer from configuration
@spec get([t()], consumer_tag()) :: {:ok, t()} | {:error, :not_found}
Find consumer by consumer_tag
Reject message