Flux AMQP v0.0.3 FluxAMQP View Source
An interface to connect to AMQP broker, sending and retrieving messages.
Link to this section Summary
Link to this section Functions
close_connection(connection)
View Source (since 0.0.1)close_connection(AMQP.Connection.t()) :: :ok | {:error, atom()}
Closes an open Connection.
Parameters
connection- TheAMQP.Connection.t/0struct.
Examples
iex> {:ok, connection} = FluxAMQP.connect(__MODULE__, only_connect?: true)
...> FluxAMQP.close_connection(connection)
:ok
connect(consumer, opts \\ [])
View Source (since 0.0.1)connect(module(), keyword()) :: {:ok, AMQP.Channel.t()} | {:ok, AMQP.Connection.t()} | {:error, atom()}
Open a Connection and configure it.
Parameters
consumer- The module which will consume AMQP messages. Acceptsmodule/0.opts- Keyword list with connection settings. Definition is the same as application configuration and the opts defined here are merged with the application configuration. Can be blank. Acceptskeyword/0.
Examples
iex> result = FluxAMQP.connect(__MODULE__, only_connect?: true)
...> with {:ok, %AMQP.Connection{}} <- result, do: :passed
:passed
iex> result = FluxAMQP.connect(__MODULE__)
...> with {:ok, %AMQP.Channel{}} <- result, do: :passed
:passed
Send AMQP message.
Parameters
payload- The message. AcceptsString.t/0.routing_key- The AMQP routing key which the message will be sent. AcceptsString.t/0.opts- Keyword list with options. Can be blank. Acceptskeyword/0.
Examples
iex> FluxAMQP.Sender.send(
...> "Hello, World!",
...> "some.amqp.route",
...> broker_uri: "amqp://guest:guest@rabbitmq",
...> close_connection?: true,
...> declare_exchange?: true,
...> reconnection: [maximum_attempts: 3, waiting_ms: 5_000]
...>)
:ok
Options
:broker- Keyword list with broker connection settings. Definition is the same as application configuration and the opts defined here are merged with the broker application configuration. Acceptskeyword/0.:channel- A validAMQP.Channel.t/0struct. If not set, a new channel will be created.:close_connection?- Iftrue, it will close the connection. Defaults totrue. Acceptsboolean/0.:connection- A validAMQP.Connection.t/0struct. If not set, a new connection will be created.:declare_exchange?- Iftrue, it will declare the AMQP exchange into channel. Defaults totrue. Acceptsboolean/0.:exchange- A string with validAMQP.Exchange.declare/4definition. If not set,amq.topicwill be used. AcceptsString.t/0.:publish_options- A Keyword list with validAMQP.Basic.publish/5options. Defaults to an empty list. Acceptskeyword/0.