AMQP exchanges route messages to queues. By default the server will have a few exchanges declared (including the default exchange ""), but additional exchanges can be declared and subsequently deleted by clients.

Both amqp_declare_exchange() and amqp_delete_exchange() will raise errors if there is a problem declaring/deleting the exchange.

amqp_declare_exchange(conn, exchange, type = "direct", passive = FALSE,
  durable = FALSE, auto_delete = FALSE, internal = FALSE, ...)

amqp_delete_exchange(conn, exchange, if_unused = FALSE)

Arguments

conn

An object returned by amqp_connect.

exchange

The name of an exchange.

type

The type of exchange. Usually one of "direct", "fanout", or "topic".

passive

When TRUE, raise an error if the exchange does not already exist.

durable

When TRUE, the exchange will persist between server restarts.

auto_delete

When TRUE, the exchange is automatically deleted when all queues have finished using it.

internal

When TRUE, the exchange cannot be used for publishing messages; it can only be bound to other exchanges. This is for creating complex routing topologies that are not visible to consumers.

...

Additional arguments, used to declare broker-specific AMQP extensions. See Details.

if_unused

Delete the exchange only if it is unused (i.e. no queues are bound to it).

Details

Additional arguments can be used to declare broker-specific extensions. An incomplete list is as follows:

"alternate-exchange"

Specify an alternate exchange to handle messages the broker is unable to route.

Examples

if (FALSE) {
conn <- amqp_connect()
amqp_declare_exchange(conn, "test_exchange", "fanout")
amqp_delete_exchange(conn, "test_exchange")
amqp_disconnect(conn)
}