lapin v0.4.0 Lapin.Channel View Source

Lapin Channel handling

Link to this section Summary

Types

Channel configuration

Consumer Prefetch

Consumer Tag

Exchange name

Queue name

Queue Arguments

Channel role

Routing key

t()

Functions

ACK message consumption

Wait for publish confirmation

Creates a channel from configuration

Find channel by consumer_tag

Find channel by exchange and routing key

Link to this section Types

Channel configuration

The following keys are supported:

  • role: channel role (atom), allowed values are:

    • :consumer: Receives messages from the channel via Lapin.Connection callbacks
    • :producer: Can publish messages to che channel
    • :passive: Used to declare channel configuration, can't receive nor publish
  • pattern: channel pattern (module using the Lapin.Pattern behaviour)
  • exchange: broker exchange (String.t)
  • queue: broker queue (String.t)

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

  • consumer_ack: send consumer ack (boolean), default: false
  • consumer_prefetch cosumer prefetch (integer | nil), default: nil
  • exchange_type: declare type of the exchange (:direct, :fanout, :topic), default: :direct
  • exchange_durable: declare exchange as durable (boolean), default: true
  • publisher_confirm: expect RabbitMQ publish confirms (boolean), default: false
  • publisher_mandatory: messages published as mandatory by default (boolean), deafault: false
  • publisher_persistent: messages published as persistent by default (boolean), deafault: false
  • queue_arguments: queue arguments (list of {string, type, value}), default: []
  • queue_durable: declare queue as durable (boolean), default: true
  • routing_key: routing_key for bindings (string), default: ""
Link to this type

consumer_prefetch() View Source
consumer_prefetch() :: integer() | nil

Consumer Prefetch

Link to this type

consumer_tag() View Source
consumer_tag() :: String.t()

Consumer Tag

Link to this type

exchange() View Source
exchange() :: String.t()

Exchange name

Queue name

Link to this type

queue_arguments() View Source
queue_arguments() :: [{String.t(), atom(), String.t()}]

Queue Arguments

Link to this type

role() View Source
role() :: :consumer | :producer | :passive

Channel role

Link to this type

routing_key() View Source
routing_key() :: String.t()

Routing key

Link to this type

t() View Source
t() :: %Lapin.Channel{
  amqp_channel: AMQP.Channel.t(),
  config: config(),
  consumer_tag: consumer_tag(),
  exchange: exchange(),
  pattern: Lapin.Pattern.t(),
  queue: queue(),
  role: role(),
  routing_key: routing_key()
}

Link to this section Functions

Link to this function

ack(map, delivery_tag) View Source
ack(t(), integer()) :: :ok | {:error, term()}

ACK message consumption

Link to this function

confirm(map) View Source
confirm(t()) :: boolean()

Wait for publish confirmation

Link to this function

create(connection, config) View Source
create(connection :: AMQP.Connection.t(), config()) ::
  {:ok, t()} | {:error, term()}

Creates a channel from configuration

Link to this function

get(channels, consumer_tag) View Source
get([t()], consumer_tag()) :: {:ok, t()} | {:error, :channel_not_found}

Find channel by consumer_tag

Link to this function

get(channels, exchange, routing_key, role) View Source
get([t()], exchange(), routing_key(), role()) ::
  {:ok, t()} | {:error, :channel_not_found}

Find channel by exchange and routing key

Link to this function

publish(map, exchange, routing_key, payload, options) View Source
publish(t(), exchange(), routing_key(), Lapin.Message.payload(), Keyword.t()) ::
  :ok | {:error, term()}

Publish message

Link to this function

reject(map, delivery_tag, requeue) View Source
reject(t(), integer(), boolean()) :: :ok | {:error, term()}

Reject message