postwait / node-amqp

[UNMAINTAINED] node-amqp is an AMQP client for nodejs
MIT License
1.69k stars 357 forks source link

Document callback parameter in queue.bind #298

Closed glenjamin closed 10 years ago

glenjamin commented 10 years ago

The implementation of this callback currently contains a "FIXME", but for the common case the callback should work fine.

testower commented 10 years ago

The problem of running multiple bind operations in parallell with their own callbacks was not be fixed by this, am I right?

I would like some pointers of best practice. I need to wait for a binding to complete before polling for data through it, and much of this happens in parallell all the way back to the client. But if there is already a binding operation in progress, issuing another one will replace the callback.

If I would like to patch node-amqp to support a separate callback for each binding operation, how would I proceed?

I posted this question to stackoverflow: http://stackoverflow.com/questions/22931748/node-amqp-multiple-bind-callbacks

glenjamin commented 10 years ago

Whenever a bind is completed, a bindOk event is emitted on the queue object, you should be able to use this to achieve what you're after without having to patch node-amqp, 4 binds would emit 4 bindOk events for example.

I'm on a phone right now, so please double-check the code/docs on this - the advice should be sound but the details may be slightly incorrect.

On 8 Apr 2014, at 04:18, Tom Erik Støwer notifications@github.com wrote:

The problem of running multiple bind operations in parallell with their own callbacks will not be fixed by this, am I right?

I would like some pointers of best practice. I need to wait for a binding to complete before polling for data through it, and much of this happens in parallell all the way back to the client. But if there is already a binding operation in progress, issuing another one will replace the callback.

If I would like to patch node-amqp to support a separate callback for each binding operation, how would I proceed?

— Reply to this email directly or view it on GitHub.

testower commented 10 years ago

The problem is that I need to know which particular binding completed. Do you have any suggestions for how to achieve that? I can't find any documentation on the bindOk event though.

glenjamin commented 10 years ago

The best docs I know of are here: https://www.rabbitmq.com/amqp-0-9-1-reference.html#class.queue

It doesn't look like the info is there, but you can try using the NODE_DEBUG_AMQP environment variable to see the protocol communication, or just subscribe to the event and see what comes out.

If the info isn't there you could achieve this by only doing one bind at a time on any given channel, perhaps using something like async.queue as the throttle. You can use multiple channels if you need higher throughput.

On 10 Apr 2014, at 11:02, Tom Erik Støwer notifications@github.com wrote:

The problem is that I need to know which particular binding completed. Do you have any suggestions for how to achieve that? I can't find any documentation on the bindOk event though.

— Reply to this email directly or view it on GitHub.

testower commented 10 years ago

Nothing comes out of the event, just an empty object {}. The async-option was the workaround I already had in place, but it's too slow. As for multiple channels, how would that work? Declare a new queue for each binding?