pluggable queue abstraction
queue.onMessage = (item:Int) -> {
return new Promise((resolve, reject) -> {
trace("got item", item);
item++;
if (item == 31) {
queue.requeue(item, 1000); // requeue with 1s delay
}
resolve(true); // ack
});
}
queue.start().then(success -> {
q.enqueue(10);
q.enqueue(20);
q.enqueue(30);
q.enqueue(40);
q.enqueue(50);
});
This is the most basic queue, it will dispatch items seqentually waiting for an ack or nack before dispatching the next item. This is purely an internal implementation for simple things (like making sure http requests are "in order" when dealing with nonces for example)
var queue:IQueue<Int> = QueueFactory.instance.createQueue(QueueFactory.SIMPLE_QUEUE);
This isnt actually a queue but can be used when an interface for a queue is required (for example its the default in the http request queue). This "queue" simply dispatches items as they come in, there is nothing sequential about this at all. It is not a queue
var queue:IQueue<Int> = QueueFactory.instance.createQueue(QueueFactory.NON_QUEUE);
var queue:IQueue<Int> = QueueFactory.createDatabase(QueueFactory.RABBITMQ_QUEUE, {
brokerUrl: "amqp://localhost",
queueName: "my-http-request-queue"
});
Note: must include queues-rabbitmq for plugin to be auto-registered