View Source AMQPHelpers.Adapter behaviour (AMQP Helpers v1.5.0)
A behaviour
for the AMQP
client implementation.
This module declares a behaviour for the AMQP
library, allowing us to use
different implementations of the underlaying AMQP interface. Check out the
AMQPHelpers.Adapters.Stub
and AMQPHelpers.Adapters.AMQP
for actual
implementations of this behaviour.
This behaviour also enables us to mock this interface in tests using libraries like Mox. Check out the libraries tests for examples about this usage.
Summary
Callbacks
Acknowledges one or more messages.
Stops the given consumer from consuming.
Closes an open Channel.
Registers a queue consumer process.
Activates publishing confirmations on the channel.
Provides an easy way to access an AMQP.Channel.t/0
.
Provides an easy way to access an AMQP.Connection.t/0
.
Returns the next message sequence number.
Negative acknowledges of one or more messages.
Opens a new channel in a previously opened connection.
Publishes a message to an Exchange.
Register a handler for confirms on channel.
Registers a handler to deal with returned messages.
Sets the message prefetch count or prefetch size.
Callbacks
@callback ack( channel :: AMQP.Channel.t(), delivery_tag :: integer(), options :: keyword() ) :: :ok | {:error, term()}
Acknowledges one or more messages.
See AMQP.Basic.ack/3
.
@callback cancel_consume( channel :: AMQP.Channel.t(), consumer_tag :: String.t(), opts :: keyword() ) :: {:ok, String.t()} | {:error, term()}
Stops the given consumer from consuming.
See AMQP.Basic.cancel/3
.
@callback close_channel(channel :: AMQP.Channel.t()) :: :ok | {:error, term()}
Closes an open Channel.
See AMQP.Channel.close/1
.
@callback consume( channel :: AMQP.Channel.t(), queue :: String.t(), consumer :: pid() | nil, options :: keyword() ) :: {:ok, String.t()} | AMQP.Basic.error()
Registers a queue consumer process.
See AMQP.Basic.consume/4
.
@callback enable_select_confirm(channel :: AMQP.Channel.t()) :: :ok | {:error, any()}
Activates publishing confirmations on the channel.
@callback fetch_application_channel(name :: binary() | atom()) :: {:ok, AMQP.Channel.t()} | {:error, any()}
Provides an easy way to access an AMQP.Channel.t/0
.
@callback fetch_application_connection(name :: binary() | atom()) :: {:ok, AMQP.Connection.t()} | {:error, any()}
Provides an easy way to access an AMQP.Connection.t/0
.
@callback get_next_delivery_tag(channel :: AMQP.Channel.t()) :: non_neg_integer()
Returns the next message sequence number.
@callback nack( channel :: AMQP.Channel.t(), delivery_tag :: integer(), options :: keyword() ) :: :ok | {:error, term()}
Negative acknowledges of one or more messages.
See AMQP.Basic.nack/3
.
@callback open_channel(connection :: AMQP.Connection.t()) :: {:ok, AMQP.Channel.t()} | {:error, term()}
Opens a new channel in a previously opened connection.
See AMQP.Channel.open/2
.
@callback publish( channel :: AMQP.Channel.t(), exchange :: AMQP.Basic.exchange(), routing_key :: AMQP.Basic.routing_key(), payload :: AMQP.Basic.payload(), options :: Keyword.t() ) :: :ok | AMQP.Basic.error()
Publishes a message to an Exchange.
See AMQP.Basic.publish/5
.
@callback register_confirm_handler(channel :: AMQP.Channel.t(), handler :: pid()) :: :ok
Register a handler for confirms on channel.
@callback register_return_handler(channel :: AMQP.Channel.t(), handler :: pid()) :: :ok
Registers a handler to deal with returned messages.
See AMQP.Basic.return/2
.
@callback set_channel_options(channel :: AMQP.Channel.t(), options :: keyword()) :: :ok | {:error, any()}
Sets the message prefetch count or prefetch size.
See AMQP.Basic.qos/2
.