Flux AMQP v0.0.5 FluxAMQP View Source
An interface to connect to AMQP broker, sending and retrieving messages.
Link to this section Summary
Functions
Closes an open Connection.
Closes an open Connection.
Open a AMQP.Connection.t/0
and configure it.
Open a AMQP.Connection.t/0
and configure it.
Open a AMQP.Channel.t/0
based on AMQP.Connection.t/0
.
Open a AMQP.Channel.t/0
based on AMQP.Connection.t/0
.
Send AMQP message.
Send AMQP message.
Link to this section Functions
close_connection(connection)
View Source (since 0.0.1)close_connection(AMQP.Connection.t()) :: :ok | {:error, :failed_to_close_connection}
Closes an open Connection.
Parameters
connection
- TheAMQP.Connection.t/0
struct.
Examples
iex> connection = FluxAMQP.connect!(__MODULE__, only_connect?: true)
...> FluxAMQP.close_connection(connection)
:ok
close_connection!(connection)
View Source (since 0.0.5)close_connection!(AMQP.Connection.t()) :: :ok
Closes an open Connection.
Similar to close_connection/1
, but raises FluxAMQP.Error.t/0
on
failure.
Examples
iex> 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.Connection.t() | AMQP.Channel.t()} | {:error, :failed_to_connect}
Open a AMQP.Connection.t/0
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. Additionally, if the option:only_connect?
istrue
, this function will not configure channel and will return aAMQP.Connection.t/0
, otherwise will configure aAMQP.Channel.t/0
and will return it. 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
connect!(consumer, opts \\ [])
View Source (since 0.0.5)connect!(module(), keyword()) :: AMQP.Connection.t() | AMQP.Channel.t()
Open a AMQP.Connection.t/0
and configure it.
Similar to connect/2
, but raises FluxAMQP.Error.t/0
on failure.
Examples
iex> result = FluxAMQP.connect!(__MODULE__, only_connect?: true)
...> with %AMQP.Connection{} <- result, do: :passed
:passed
iex> result = FluxAMQP.connect!(__MODULE__)
...> with %AMQP.Channel{} <- result, do: :passed
:passed
open_channel(connection)
View Source (since 0.0.5)open_channel(AMQP.Connection.t()) :: {:ok, AMQP.Channel.t()} | {:error, :failed_to_open_channel}
Open a AMQP.Channel.t/0
based on AMQP.Connection.t/0
.
Parameters
connection
- TheAMQP.Connection.t/0
struct.
Examples
iex> connection = FluxAMQP.connect!(MODULE, only_connect?: true) ...> result = FluxAMQP.open_channel(connection) ...> with {:ok, %AMQP.Channel{}} <- result, do: :passed :passed
open_channel!(connection)
View Source (since 0.0.5)open_channel!(AMQP.Connection.t()) :: AMQP.Channel.t()
Open a AMQP.Channel.t/0
based on AMQP.Connection.t/0
.
Similar to open_channel/1
, but raises FluxAMQP.Error.t/0
on failure.
Examples
iex> connection = FluxAMQP.connect!(MODULE, only_connect?: true) ...> result = FluxAMQP.open_channel!(connection) ...> with %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.send("Hello, World!", "some.amqp.route")
: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/0
struct. 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/0
struct. If not set, a new connection will be created.:publish_options
- A Keyword list with validAMQP.Basic.publish/5
options. Defaults to an[persistent: true]
. Acceptskeyword/0
.
Send AMQP message.
Similar to send/3
, but raises FluxAMQP.Error.t/0
on failure.
Examples
iex> FluxAMQP.send!("Hello, World!", "some.amqp.route")
:ok