AMQPHelpers.Adapter behaviour (AMQP Helpers v1.4.1)

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.

Link to this section 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.

Link to this section Callbacks

Link to this callback

ack(channel, delivery_tag, options)

Specs

ack(
  channel :: AMQP.Channel.t(),
  delivery_tag :: integer(),
  options :: keyword()
) :: :ok | {:error, term()}

Acknowledges one or more messages.

See AMQP.Basic.ack/3.

Link to this callback

cancel_consume(channel, consumer_tag, opts)

Specs

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.

Link to this callback

close_channel(channel)

Specs

close_channel(channel :: AMQP.Channel.t()) :: :ok | {:error, term()}

Closes an open Channel.

See AMQP.Channel.close/1.

Link to this callback

consume(channel, queue, consumer, options)

Specs

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.

Link to this callback

enable_select_confirm(channel)

Specs

enable_select_confirm(channel :: AMQP.Channel.t()) :: :ok | {:error, any()}

Activates publishing confirmations on the channel.

See AMQP.Confirm.select/1.

Link to this callback

fetch_application_channel(name)

Specs

fetch_application_channel(name :: binary() | atom()) ::
  {:ok, AMQP.Channel.t()} | {:error, any()}

Provides an easy way to access an AMQP.Channel.t/0.

See AMQP.Application.get_channel/1.

Link to this callback

fetch_application_connection(name)

Specs

fetch_application_connection(name :: binary() | atom()) ::
  {:ok, AMQP.Connection.t()} | {:error, any()}

Provides an easy way to access an AMQP.Connection.t/0.

See AMQP.Application.get_connection/1.

Link to this callback

get_next_delivery_tag(channel)

Specs

get_next_delivery_tag(channel :: AMQP.Channel.t()) :: non_neg_integer()

Returns the next message sequence number.

See AMQP.Confirm.next_publish_seqno/1.

Link to this callback

nack(channel, delivery_tag, options)

Specs

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.

Link to this callback

open_channel(connection)

Specs

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.

Link to this callback

publish(channel, exchange, routing_key, payload, options)

Specs

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.

Link to this callback

register_confirm_handler(channel, handler)

Specs

register_confirm_handler(channel :: AMQP.Channel.t(), handler :: pid()) :: :ok

Register a handler for confirms on channel.

See AMQP.Confirm.register_handler/2.

Link to this callback

register_return_handler(channel, handler)

Specs

register_return_handler(channel :: AMQP.Channel.t(), handler :: pid()) :: :ok

Registers a handler to deal with returned messages.

See AMQP.Basic.return/2.

Link to this callback

set_channel_options(channel, options)

Specs

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.