AMQP queues store messages that can be consumed by clients. They must be declared before use and bound to an exchange so that messages can be routed to them.

The amqp_declare_tmp_queue() function is a shortcut for declaring a non-durable (also called "transient") queue with a server-generated name.

Both amqp_declare_queue() and amqp_delete_queue() will raise errors if there is a problem declaring/deleting the queue.

amqp_declare_queue(conn, queue = "", passive = FALSE, durable = FALSE,
  exclusive = FALSE, auto_delete = FALSE, ...)

amqp_declare_tmp_queue(conn, passive = FALSE, exclusive = FALSE, ...)

amqp_delete_queue(conn, queue, if_unused = FALSE, if_empty = FALSE)

Arguments

conn

An object returned by amqp_connect.

queue

The name of a queue. If this is empty (the default), the server will generate a random name for the queue itself.

passive

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

durable

When TRUE, the queue will persist between server restarts.

exclusive

When TRUE, the queue will only be accessible to the current connection, and will be deleted when that connection closes.

auto_delete

When TRUE, the queue is automatically deleted when all consumers have finished with it (i.e. their connections have closed). This does not come into effect until the queue has at least one consumer.

...

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

if_unused

Delete the queue only if it is unused.

if_empty

Delete the queue only if it is empty.

Value

amqp_declare_tmp_queue() will return the name of the new, temporary queue, while amqp_declare_queue() will return an object containing some additional information.

amqp_delete_queue() will return the number of messages in the queue when it was deleted, invisibly.

Details

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

"x-dead-letter-exchange"

Specify a dead letter exchange for the queue.

"x-dead-letter-routing-key"

Specify a dead letter routing key for the queue.

"x-expires"

Specify a queue expiration, in seconds.

"x-max-length"

Specify the maximum number of messages to store in the queue before it overflows.

"x-max-length-bytes"

Specify the total number of bytes that messages can take up in the queue before it overflows.

"x-max-priority"

Specify the maximum priority supported by the queue.

"x-message-ttl"

Specify a message time-to-live, in seconds.

"x-overflow"

Specify queue overflow behaviour. Either "drop-head" (the default) or "reject-publish".

"x-queue-mode"

Specify queue mode. Either "normal" (the default) or "lazy".

"x-single-active-consumer"

Specify that the queue can only have a single active consumer.

Examples

if (FALSE) {
conn <- amqp_connect()
amqp_declare_queue(conn, "test.queue", auto_delete = TRUE)
amqp_delete_queue(conn, "test.queue")
amqp_disconnect(conn)
}