-
Notifications
You must be signed in to change notification settings - Fork 4
Queue Storage
The queue storage API functionality can be put into two groups: (1) methods provided with 'storage' that allow manipulation of the queues themselves and (2) methods on the 'queue' object used to manipulate messages on the queue.
These methods are accessible via the storage
object. In reality, the functionality is found in static methods of the Table
object -- these proxy methods are provided for convenience.
Creates a new queue with the supplied queueName
on this storage account. Optional callback
is invoked with a reference to the newly created queue as the second argument.
Lists all queues in this storage account. Optional 'prefix' will return only those queues starting with prefix
. Passing the option {limit:n}
will return only the first n queues. Optional callback
is invoked with an array of container names as the second argument.
With no callback, an EventEmitter is immediately returned which will emit a 'data' event with each queue name and an 'end' event with a total count of queues.
For example, a simple way to return a count of queues:
storage.listQueues().on('end', function(err, count) {
console.log(count);
});
Removes the queue specified by queueName
. Optional callback
is invoked with any errors.
Returns a reference to a queue (the same as returned by storage.createQueue
).
The createQueue
and queue
methods above return an instance of the Queue
object. This object provides the following methods:
Puts a message
on the queue. Optional callback
is invoked with any errors.
Checks whether there is a message waiting on the queue. If there is a message, it is passed as the second parameter to callback
without being removed from the queue. The contents of the message are in message.body
.
Checks whether there is a message waiting on the queue. If there is a message, it is passed to callback
as the second parameter and marked 'invisible' for the default period of time. A 'done' function is passed as the third parameter to callback
. Invoking this function will remove the message from the queue. This 'done' function obeys the 'error' parameter semantics and will only remove the message from the queue if the first parameter to the function is falsy. This means you can pass the 'done' function as a callback to a function you invoke within the queue.get
callback. For example:
queue.get(function(err, msg, done) {
doSomethingWithMessage(msg, done);
}
Removes the message (identified by the id
and receipt
properties of the message, or simply the message itself) from the queue. Optional callback
is invoked with any errors.
This will check the queue for a new message every t
milliseconds. If a message is found, the queue will emit a message
event that contains the message and a 'done' function. This 'done' function works exactly like the one provided by queue.get
above. To stop polling for new messages, call poll(0)
.
Clears the queue of all messages. Optional callback
is invoked with any errors.
Returns the underlying BlobService object from the Azure SDK.