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
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
Publish message
Reject message
Link to this section Types
config()
View Source
config() :: Keyword.t()
config() :: Keyword.t()
Channel configuration
The following keys are supported:
role: channel role (
atom
), allowed values are::consumer
: Receives messages from the channel viaLapin.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: ""
consumer_prefetch()
View Source
consumer_prefetch() :: integer() | nil
consumer_prefetch() :: integer() | nil
Consumer Prefetch
consumer_tag()
View Source
consumer_tag() :: String.t()
consumer_tag() :: String.t()
Consumer Tag
exchange()
View Source
exchange() :: String.t()
exchange() :: String.t()
Exchange name
queue()
View Source
queue() :: String.t()
queue() :: String.t()
Queue name
queue_arguments() View Source
Queue Arguments
role()
View Source
role() :: :consumer | :producer | :passive
role() :: :consumer | :producer | :passive
Channel role
routing_key()
View Source
routing_key() :: String.t()
routing_key() :: String.t()
Routing key
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()
}
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
ack(map, delivery_tag) View Source
ACK message consumption
confirm(map) View Source
Wait for publish confirmation
create(connection, config)
View Source
create(connection :: AMQP.Connection.t(), config()) ::
{:ok, t()} | {:error, term()}
create(connection :: AMQP.Connection.t(), config()) :: {:ok, t()} | {:error, term()}
Creates a channel from configuration
get(channels, consumer_tag)
View Source
get([t()], consumer_tag()) :: {:ok, t()} | {:error, :channel_not_found}
get([t()], consumer_tag()) :: {:ok, t()} | {:error, :channel_not_found}
Find channel by consumer_tag
get(channels, exchange, routing_key, role)
View Source
get([t()], exchange(), routing_key(), role()) ::
{:ok, t()} | {:error, :channel_not_found}
get([t()], exchange(), routing_key(), role()) :: {:ok, t()} | {:error, :channel_not_found}
Find channel by exchange and routing key
publish(map, exchange, routing_key, payload, options)
View Source
publish(t(), exchange(), routing_key(), Lapin.Message.payload(), Keyword.t()) ::
:ok | {:error, term()}
publish(t(), exchange(), routing_key(), Lapin.Message.payload(), Keyword.t()) :: :ok | {:error, term()}
Publish message
reject(map, delivery_tag, requeue) View Source
Reject message