# 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.2"}]

`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. Options are:

  - `:uri` - The AMQP Broker URI. Defaults to `amqp://guest:guest@rabbitmq`.

  - `:connection` - Set the AMQP broker connection. Options are:

    - `:reattempt_connection_on_failure?` - If `true`, when a connection to AMQP
      broker fails, a reattempt will be performed. Defaults to `true`

    - `:reattempt` - Set the reattempt settings. 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`.

      - `:waiting_ms` - How many milliseconds should wait before reattempting
        connection. Defaults to `10_000`.

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