amqp_director v1.1.1 AmqpDirector View Source
Documentation for AmqpDirector.
This module provides wrapping for the Erlang code and is intended to be used with Elixir applications.
Link to this section Summary
Types
AMQP RPC Client configuraion options
RabbitMQ broker connection options
The content type of the AMQP message payload
The handler function type for the AMQP RPC Server
The type that a AMQP RPC Server handler function must return
AMQP RPC Pull Client configuraion options
Queue definition instructions
AMQP RPC Server configuration options
Functions
Creates a child specification for an AMQP RPC client
Declares an exchange on the AMQP Broker
Creates a child specification for an AMQP RPC pull client
Binds a queue to an exchange
Declares a queue on the AMQP Broker
Creates a child specification for an AMQP RPC server
Link to this section Types
client_option() :: {:app_id, String.t()} | {:queue_definitions, [queue_definition()]} | {:reply_queue, String.t()} | {:no_ack, boolean()}
AMQP RPC Client configuraion options.
:app_id
- Specifies the identitifier of the client.:queue_definition
- A list of instructions for setting up the queues and exchanges. The RPC Client will call these during its initialization. The instructions should be created usingexchange_declare/2
,queue_declare/2
andqueue_bind/3
. E.g.
{:queue_definitions, [
AmqpDirector.exchange_declare("my_exchange", type: "topic"),
AmqpDirector.queue_declare("my_queue", exclusive: true),
AmqpDirector.queue_bind("my_queue", "my_exchange", "some.topic.*")
]}
:reply_queue
- Allows naming for the reply queue. Defaults to empty name, making the RabbitMQ broker auto-generate the name.:no_ack
- Specifies if the client should NOT auto-acknowledge replies. Defaults tofalse
.
connection_option() :: {:host, String.t()} | {:port, non_neg_integer()} | {:username, String.t()} | {:password, String.t()} | {:virtual_host, String.t()}
RabbitMQ broker connection options.
The content type of the AMQP message payload.
handler() :: (payload :: binary(), content_type(), type :: String.t() -> handler_return_type())
The handler function type for the AMQP RPC Server.
handler_return_type() :: {:reply, payload :: binary(), content_type()} | :reject | :reject_no_requeue | {:reject_dump_msg, String.t()} | :ack
The type that a AMQP RPC Server handler function must return.
pull_client_option() :: {:app_id, String.t()} | {:queue_definitions, [queue_definition()]}
AMQP RPC Pull Client configuraion options.
:app_id
- Specifies the identitifier of the client.:queue_definition
- A list of instructions for setting up the queues and exchanges. The RPC Client will call these during its initialization. The instructions should be created usingexchange_declare/2
,queue_declare/2
andqueue_bind/3
. E.g.
{:queue_definitions, [
AmqpDirector.exchange_declare("my_exchange", type: "topic"),
AmqpDirector.queue_declare("my_queue", exclusive: true),
AmqpDirector.queue_bind("my_queue", "my_exchange", "some.topic.*")
]}
queue_definition() :: exchange_declare() | queue_declare() | queue_bind()
Queue definition instructions.
AMQP RPC Server configuration options.
:consume_queue
- Specifies the name of the queue on which the server will consume messages.:consumer_tag
- Specifies the tag that the server will be identified when listening on the queue.:queue_definition
- A list of instructions for setting up the queues and exchanges. The RPC Server will call these during its initialization. The instructions should be created usingexchange_declare/2
,queue_declare/2
andqueue_bind/3
. E.g.
{:queue_definitions, [
AmqpDirector.exchange_declare("my_exchange", type: "topic"),
AmqpDirector.queue_declare("my_queue", exclusive: true),
AmqpDirector.queue_bind("my_queue", "my_exchange", "some.topic.*")
]}
:no_ack
- Specifies if the server should NOT auto-acknowledge consumed messages. Defaults tofalse
.:qos
- Specifies the prefetch count on the consume queue. Defaults to2
.:reply_persistent
- Specifies the delivery mode for the AMQP replies. Setting this totrue
will make the broker log the messages on disk. See AMQP specification for more information. Defaults tofalse
Link to this section Functions
client_child_spec(atom(), [connection_option()], [client_option()]) :: Supervisor.child_spec()
Creates a child specification for an AMQP RPC client.
This specification allows for RPC clients to be nested under any supervisor in the application using AmqpDirector. The RPC
client can perform queue initialization. It will also create a reply queue to consume replies on. The client can then be used
using AmqpDirector.Client
module API. See client_option/0
for configuration options.
The client handles reconnecting by itself.
Declares an exchange on the AMQP Broker.
This function is intended to be using within :queue_definitions
configuration parameter of a client or a server. See
client_option/0
or server_option/0
for details.
Available options are: :passive
, :durable
, :auto_delete
, :internal
and :arguments
. See AMQP specification for details on exchange
declaration.
pull_client_child_spec(atom(), [connection_option()], [pull_client_option()]) :: Supervisor.child_spec()
Creates a child specification for an AMQP RPC pull client.
This specification allows for RPC clients to be nested under any supervisor in the application using AmqpDirector. The pull client
uses the Synchronous Pull (#basic.get{}
) over AMQP. The client can then be used using AmqpDirector.PullClient
module API.
See pull_client_option/0
for configuration options.
The client handles reconnecting by itself.
Binds a queue to an exchange.
This function is intended to be using within :queue_definitions
configuration parameter of a client or a server. See
client_option/0
or server_option/0
for details. See AMQP specification for details of queue binding.
Declares a queue on the AMQP Broker.
This function is intended to be using within :queue_definitions
configuration parameter of a client or a server. See
client_option/0
or server_option/0
for details.
Available options are: :passive
, :durable
, :exclusive
, :auto_delete
and :arguments
. See AMQP specification for details on
queue declaration.
server_child_spec(atom(), handler(), [connection_option()], non_neg_integer(), [ server_option() ]) :: Supervisor.child_spec()
Creates a child specification for an AMQP RPC server.
This specification allows for RPC servers to be nested under any supervisor in the application using AmqpDirector. The RPC Server
will initialize the queues it is instructed to and will then consume messages on the queue specified. The handler function will
be called to handle each request. See server_option/0
for configuration options and handler/0
for the type spec
of the handler function.
The server handles reconnecting by itself.