AMQP.Queue

Functions to operate on Queues.

Source

Summary

bind(channel, queue, exchange, options \\ [])

Binds a Queue to an Exchange

consumer_count(channel, queue)

Returns a number of active consumers on the queue

declare(channel, queue \\ "", options \\ [])

Declares a queue. The optional queue parameter is used to set the name. If set to an empty string (default), the server will assign a name

delete(channel, queue, options \\ [])

Deletes a Queue by name

empty?(channel, queue)

Returns true if queue is empty (has no messages ready), false otherwise

message_count(channel, queue)

Returns the number of messages that are ready for delivery (e.g. not pending acknowledgements) in the queue

purge(channel, queue)

Discards all messages in the Queue

status(chan, queue)

Returns the message count and consumer count for the given queue. Uses Queue.declare with the passive option set

subscribe(channel, queue, fun)

Convenience to consume messages from a Queue

unbind(channel, queue, exchange, options \\ [])

Unbinds a Queue from an Exchange

unsubscribe(channel, consumer_tag)

Convenience to end a Queue consumer

Functions

bind(channel, queue, exchange, options \\ [])

Binds a Queue to an Exchange

Source
consumer_count(channel, queue)

Returns a number of active consumers on the queue

Source
declare(channel, queue \\ "", options \\ [])

Declares a queue. The optional queue parameter is used to set the name. If set to an empty string (default), the server will assign a name.

Besides the queue name, the following options can be used:

Options

  • :durable - If set, keeps the Queue between restarts of the broker
  • :auto-delete - If set, deletes the Queue once all subscribers disconnect
  • :exclusive - If set, only one subscriber can consume from the Queue
  • :passive - If set, raises an error unless the queue already exists
Source
delete(channel, queue, options \\ [])

Deletes a Queue by name

Source
empty?(channel, queue)

Returns true if queue is empty (has no messages ready), false otherwise

Source
message_count(channel, queue)

Returns the number of messages that are ready for delivery (e.g. not pending acknowledgements) in the queue

Source
purge(channel, queue)

Discards all messages in the Queue

Source
status(chan, queue)

Returns the message count and consumer count for the given queue. Uses Queue.declare with the passive option set.

Source
subscribe(channel, queue, fun)

Convenience to consume messages from a Queue.

The handler function must have arity 2 and will receive as arguments a binary with the message payload and a Map with the message properties.

The consumed message will be acknowledged after executing the handler function. If an exception is raised by the handler function, the message is rejected.

This convenience function will spawn a process and register it using AMQP.Basic.consume.

Source
unbind(channel, queue, exchange, options \\ [])

Unbinds a Queue from an Exchange

Source
unsubscribe(channel, consumer_tag)

Convenience to end a Queue consumer.

Source