AMQP.Queue
Functions to operate on Queues.
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 |
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 |
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
Binds a Queue to an Exchange
Returns a number of active consumers on the queue
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
Deletes a Queue by name
Returns true if queue is empty (has no messages ready), false otherwise
Returns the number of messages that are ready for delivery (e.g. not pending acknowledgements) in the queue
Discards all messages in the Queue
Returns the message count and consumer count for the given queue.
Uses Queue.declare with the passive
option set.
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.
Unbinds a Queue from an Exchange
Convenience to end a Queue consumer.