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.
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 atBackoff.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 atAMQP.Connection.open/2.qos_options: configures the consumer QoS options. More info atAMQP.Basic.qos/2.globaloption does not apply in this context.queue: the name of the queue for consuming requests. Required.message_handler: the function of the typemessage_handler/0that will handle request received by the Consumer.request_handler_supervisor: an instance of aTask.Supervisorto 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
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.