Closed naartjie closed 8 years ago
I ran into wanting to promisify more of the Queue functions, modularize them, and allow them to be re-used. While this might not be the best answer to your question I created individual modules for my Queues around the jackrabbit instance. Heres a very cliffnotesey idea of what I did.
var QueueConnection = // the jackrabbit connection,
key = // the key;
var Queue = {
queueConnection : QueueConnection ,
key : key,
attach : function() {
return new Promise(function(resolve, reject){
Queue.queueConnection.create(Queue.key, {prefetch : 1}, function(){
resolve(true);
}.bind(Queue));
}.bind(Queue));
},
publish : function() {
......
}
}
etc, etc.
The attach method will help your prior problem. And you can wrap the synchronous .publish()
method in a promise too if you'd like, there's nothing wrong with that
Thanks for sharing this @stephengardner, I haven't had time to try it out. I got pulled off onto other things, and since my initial implementation seems to be solid, I haven't been pulled back to improve on it.
I'm going to close the issue for now. It would be nice to have a promisified version to get delivery guarantees, but I don't know enough about AMQP to contribute and help out here.
I was wondering if there is any way of knowing if the publish() fails/succeeds. I had an issue where I deployed to production and a queue hadn't been created yet (I created it on the consumer), and it was failing silently.
This might be related to #3, but I just wanted to check if anything has changed on this?