Plug.AMQP.Consumer (PlugAMQP v0.6.0) View Source

A consumer for AMQP protocol.

This module provides a consumer for managing asynchronous remote procedure calls that expect no response.

Usage

To use this consumer we must provide a message_handler/0 function. The consumer will call this function to manage requests and acknowledge messages.

Link to this section Summary

Types

A list of headers

A handler for managing requests.

A set of options available to configure the AMQP Consumer.

A list of option/0s.

The payload of a request or a response.

Functions

Returns a specification to start this module under a supervisor.

Starts a new AMQP consumer-producer.

Link to this section Types

Specs

headers() :: list()

A list of headers

Specs

message_handler() ::
  (pid(), payload(), headers() -> :ok | :error)
  | {:module, :atom}
  | {:module, :atom, any()}

A handler for managing requests.

Specs

option() ::
  {:backoff, Backoff.options()}
  | {:connection_name, String.t()}
  | {:connection_options, keyword() | String.t()}
  | {:message_handler, message_handler()}
  | {:message_handler_supervisor, Supervisor.supervisor()}
  | {:qos_options, keyword()}
  | {:queue, String.t()}

A set of options available to configure the AMQP Consumer.

Note that queue option is required.

  • backoff: how the backoff delay should behave. More info at Backoff.options/0.

  • connection_name: the name of the connections created by the AMQP Consumer.

  • connection_options: configures the broker connection. All available options are available at AMQP.Connection.open/2.

  • qos_options: configures the consumer QoS options. More info at AMQP.Basic.qos/2. global option does not apply in this context.

  • queue: the name of the queue for consuming requests. Required.

  • message_handler: the function of the type message_handler/0 that will handle request received by the Consumer.

  • request_handler_supervisor: an instance of a Task.Supervisor to supervise handlers. The Consumer will use this supervisor to run request handlers, managing any kind of error, raise or exit produced by the handler.

Specs

options() :: [option() | {atom(), any()}]

A list of option/0s.

Specs

payload() :: String.t()

The payload of a request or a response.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Specs

start_link(options()) :: GenServer.on_start()

Starts a new AMQP consumer-producer.