rbmq19 v0.4.0 RBMQ.Connection.Helper

Helper functions to manage connections with AMQP.

This module produces verbose debug logs.

Summary

Functions

Bind AMQP queue to Exchange

Gracefully close AMQP channel

Declare AMQP exchange. Exchange is durable whenever queue is durable

Declare AMQP queue. You can omit error_queue, then dead letter queue won’t be created. Dead letter queue is hardcoded to be durable

Same as open_channel!/1, but returns {:ok, conn} or {:error, reason} tuples

Open new AMQP channel inside a connection

Same as open_connection!/1, but returns {:ok, conn} or {:error, reason} tuples

Open AMQP connection

Set channel QOS policy. Especially useful when you want to limit number of unacknowledged request per worker

Functions

bind_queue(chan, queue, exchange, opts)

Bind AMQP queue to Exchange.

See: https://hexdocs.pm/amqp/AMQP.Queue.html#bind/4

close_channel(chan)

Gracefully close AMQP channel.

declare_exchange(chan, exchange, type \\ :direct, opts \\ [])

Declare AMQP exchange. Exchange is durable whenever queue is durable.

Types:

  • :direct - direct exchange.
  • :fanout - fanout exchange.
  • :topic - topic exchange.
  • :headers - headers exchange.

See: https://hexdocs.pm/amqp/AMQP.Queue.html#declare/3

declare_queue(chan, queue, error_queue, opts)

Declare AMQP queue. You can omit error_queue, then dead letter queue won’t be created. Dead letter queue is hardcoded to be durable.

Options

  • :durable - If set, keeps the Queue between restarts of the broker
  • :auto-delete - If set, deletes the Queue once all subscribers disconnect
  • :exclusive - If set, only one subscriber can consume from the Queue
  • :passive - If set, raises an error unless the queue already exists

See: https://hexdocs.pm/amqp/AMQP.Queue.html#declare/3

open_channel(conn)

Same as open_channel!/1, but returns {:ok, conn} or {:error, reason} tuples.

open_channel!(conn)

Open new AMQP channel inside a connection.

See: https://hexdocs.pm/amqp/AMQP.Channel.html#open/1

open_connection(conn_opts)

Same as open_connection!/1, but returns {:ok, conn} or {:error, reason} tuples.

open_connection!(conn_opts)

Open AMQP connection.

Options

  • :username - The name of a user registered with the broker (defaults to “guest”);
  • :password - The password of user (defaults to “guest”);
  • :virtual_host - The name of a virtual host in the broker (defaults to “/“);
  • :host - The hostname of the broker (defaults to “localhost”);
  • :port - The port the broker is listening on (defaults to 5672);
  • :channel_max - The channel_max handshake parameter (defaults to 0);
  • :frame_max - The frame_max handshake parameter (defaults to 0);
  • :heartbeat - The hearbeat interval in seconds (defaults to 0 - turned off);
  • :connection_timeout - The connection timeout in milliseconds (defaults to 15_000);
  • :ssl_options - Enable SSL by setting the location to cert files (defaults to none);
  • :client_properties - A list of extra client properties to be sent to the server, defaults to [];
  • :socket_options - Extra socket options. These are appended to the default options. See http://www.erlang.org/doc/man/inet.html#setopts-2 and http://www.erlang.org/doc/man/gen_tcp.html#connect-4 for descriptions of the available options.

See: https://hexdocs.pm/amqp/AMQP.Connection.html#open/1

set_channel_qos(chan, opts)

Set channel QOS policy. Especially useful when you want to limit number of unacknowledged request per worker.

Options

  • :prefetch_size - Limit of unacknowledged messages (in bytes).
  • :prefetch_count - Limit of unacknowledged messages (count).
  • :global - If global is set to true this applies to the entire Connection, otherwise it applies only to the specified Channel.

See: https://hexdocs.pm/amqp/AMQP.Basic.html#qos/2