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

Link to this callback

ack(channel, delivery_tag, options)

View Source
@callback 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)

View Source
@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.

Link to this callback

consume(channel, queue, consumer, options)

View Source
@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.

Link to this callback

enable_select_confirm(channel)

View Source
@callback 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)

View Source
@callback 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)

View Source
@callback 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)

View Source
@callback 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)

View Source
@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.

Link to this callback

open_channel(connection)

View Source
@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.

Link to this callback

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

View Source
@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.

Link to this callback

register_confirm_handler(channel, handler)

View Source
@callback 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)

View Source
@callback 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)

View Source
@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.