lapin v0.1.5 Lapin.Connection

RabbitMQ connection handler

Link to this section Summary

Types

Channel configuration

Connection configuration

Exchange name

Module conforming to Lapin.Pattern

Queue name

Channel role

Routing key

t()

Connection

Functions

Closes the connection

Publishes a message to the specified exchange with the given routing_key

Starts a Lapin.Connection with the specified configuration

Link to this section Types

Link to this type channel_config()
channel_config() :: Keyword.t()

Channel configuration

The following keys are supported:

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

    • :consumer: Receives messages from the channel via the worker module
    • :producer: Can publish messages to che channel
    • :passive: Used to declare channel configuration, can’t receive nor publish
  • worker: channel worker (module conforming to the Lapin.Worker behaviour)
  • exchange: broker exchange (String.t)
  • queue: broker queue (String.t)

If using the default Lapin.Pattern 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 config()
config() :: [{:channels, [channel_config()]}]

Connection configuration

The following keys are supported:

  • host: broker hostname (string | charlist), default: ‘localhost’
  • port: broker port (string | integer), default: 5672
  • virtual_host: broker vhost (string), default: “”
  • username: username (string)
  • password: password (string)
  • auth_mechanisms: broker auth_mechanisms ([:amqplain | :external | :plain]), default: amqp_client default
  • ssl_options: ssl options ([:ssl:ssl_option]), default: none
  • channels: channels to configure ([channel_config]), default: []
Link to this type exchange()
exchange() :: String.t()

Exchange name

Link to this type pattern()
pattern() :: Lapin.Pattern

Module conforming to Lapin.Pattern

Link to this type queue()
queue() :: String.t()

Queue name

Link to this type role()
role() :: :consumer | :producer | :passive

Channel role

Link to this type routing_key()
routing_key() :: String.t()

Routing key

Connection

Link to this section Functions

Link to this function close(connection)
close(connection :: t()) :: nil

Closes the connection

Link to this function publish(connection, exchange, routing_key, message, options \\ [])
publish(connection :: t(), exchange(), routing_key(), message :: Lapin.Message.t(), options :: Keyword.t()) :: Lapin.Worker.on_callback()

Publishes a message to the specified exchange with the given routing_key

Link to this function start_link(configuration, options \\ [])
start_link(config(), options :: GenServer.options()) :: GenServer.on_start()

Starts a Lapin.Connection with the specified configuration