Amqpx.Exchange (amqpx v6.0.2)
Functions to operate on Exchanges.
Link to this section Summary
Functions
Binds an Exchange to another Exchange using the exchange.bind Amqpx method (a RabbitMQ-specific extension).
Declares an Exchange. The default Exchange type is direct
.
Deletes an Exchange by name. When an Exchange is deleted all bindings to it are also deleted.
Convenience function to declare an Exchange of type direct
.
Convenience function to declare an Exchange of type fanout
.
Convenience function to declare an Exchange of type topic
.
Unbinds an Exchange from another Exchange or a Queue using the exchange.unbind Amqpx method (a RabbitMQ-specific extension).
Link to this section Functions
bind(channel, destination, source, options \\ [])
@spec bind( Amqpx.Channel.t(), destination :: String.t(), source :: String.t(), keyword() ) :: :ok | Amqpx.Basic.error()
Binds an Exchange to another Exchange using the exchange.bind Amqpx method (a RabbitMQ-specific extension).
options
Options
:routing_key
- the routing key to use for the binding. Defaults to""
.:no_wait
- If set, the bind operation is asynchronous. Defaults tofalse
.:arguments
- A list of arguments to pass when binding (of typeAmqpx.arguments/0
). See the README for more information. Defaults to[]
.
declare(channel, exchange, type \\ :direct, options \\ [])
@spec declare(Amqpx.Channel.t(), Amqpx.Basic.exchange(), type :: atom(), keyword()) :: :ok | Amqpx.Basic.error()
Declares an Exchange. The default Exchange type is direct
.
Amqpx 0-9-1 brokers provide four pre-declared exchanges:
-
:direct
exchange: (empty string) oramq.direct
-
:fanout
exchange:amq.fanout
-
:topic
exchange:amq.topic
-
:headers
exchange:amq.match
(andamq.headers
in RabbitMQ)
Besides the exchange name and type, the following options can be used:
options
Options
:durable
- If set, keeps the Exchange between restarts of the broker;:auto_delete
- If set, deletes the Exchange once all queues unbind from it;:passive
- If set, returns an error if the Exchange does not already exist;:internal
- If set, the exchange may not be used directly by publishers, but only when bound to other exchanges. Internal exchanges are used to construct wiring that is not visible to applications.:no_wait
- If set, the declare operation is asynchronous. Defaults tofalse
.:arguments
- A list of arguments to pass when declaring (of typeAmqpx.arguments/0
). See the README for more information. Defaults to[]
.
delete(channel, exchange, options \\ [])
@spec delete(Amqpx.Channel.t(), Amqpx.Basic.exchange(), keyword()) :: :ok | Amqpx.Basic.error()
Deletes an Exchange by name. When an Exchange is deleted all bindings to it are also deleted.
options
Options
:if_unused
- If set, the server will only delete the exchange if it has no queue bindings.:no_wait
- If set, the delete operation is asynchronous. Defaults tofalse
.
direct(channel, exchange, options \\ [])
@spec direct(Amqpx.Channel.t(), Amqpx.Basic.exchange(), keyword()) :: :ok | Amqpx.Basic.error()
Convenience function to declare an Exchange of type direct
.
options
Options
This function takes the same options as declare/4
.
fanout(channel, exchange, options \\ [])
@spec fanout(Amqpx.Channel.t(), Amqpx.Basic.exchange(), keyword()) :: :ok | Amqpx.Basic.error()
Convenience function to declare an Exchange of type fanout
.
options
Options
This function takes the same options as declare/4
.
topic(channel, exchange, options \\ [])
@spec topic(Amqpx.Channel.t(), Amqpx.Basic.exchange(), keyword()) :: :ok | Amqpx.Basic.error()
Convenience function to declare an Exchange of type topic
.
options
Options
This function takes the same options as declare/4
.
unbind(channel, destination, source, options \\ [])
@spec unbind( Amqpx.Channel.t(), destination :: String.t(), source :: String.t(), keyword() ) :: :ok | Amqpx.Basic.error()
Unbinds an Exchange from another Exchange or a Queue using the exchange.unbind Amqpx method (a RabbitMQ-specific extension).
options
Options
:routing_key
- the routing key to use for the binding. Defaults to""
.:no_wait
- If set, the declare operation is asynchronous. Defaults tofalse
.:arguments
- A list of arguments to pass when declaring (of typeAmqpx.arguments/0
). See the README for more information. Defaults to[]
.