Flux AMQP

Interface to connect to AMQP broker, sending and retrieving messages.

It uses AMQP, check their documentation to understand how this library perform the connection, configuration, consumption and delivery of AMQP messages.

Usage

Add Flux AMQP as a dependency in your mix.exs file:

def deps do
  [{:flux_amqp, "~> 0.0.3"}]
end

FluxAMQP describes how to define and close a connection and how to send a message.

FluxAMQP.Consumer describes how to consume AMQP messages.

Application Configuration

import Config

# Default values
config :flux_amqp,
  broker: [
    uri: "amqp://guest:guest@rabbitmq",
    connection: [
      reattempt_connection_on_failure?: true,
      reattempt: [
        maximum_attempts: :infinity,
        waiting_ms: 10_000
      ]
    ]
  ],
  routing_keys: []

Configuration Options

  • :broker - Set the AMQP broker. Accepts keyword/0. Options are:

    • :uri - The AMQP Broker URI. Defaults to amqp://guest:guest@rabbitmq. Accepts String.t/0.

    • :connection - Set the AMQP broker connection. Accepts keyword/0. Options are:

      • :reattempt_connection_on_failure? - If true, when a connection to AMQP broker fails, a reattempt will be performed. Defaults to true. Accepts boolean/0.

      • :reattempt - Set the reattempt settings. Accepts keyword/0. Options are:

        • :maximum_attempts - How many attempts should be performed in case of connection failure. If set to :infinity, it will try until connection succeeds. Defaults to :infinity. Accepts integer/0 or :infinity.

        • :waiting_ms - How many milliseconds should wait before reattempting connection. Defaults to 10_000. Accepts integer/0.

  • :routing_keys - The AMQP routing keys which the messages will be consumed. A routing key can be defined as a tuple {routing_key, exchange} or as the routing_key (the exchange will be set to amq.topic). Defaults to an empty list. Accepts String.t/0 or tuple/0. Check AMQP.Exchange.declare/4 for more information about exchange definition.