postwait/node-amqp — pull request #170 by sbellone (2013-03-21 14:01:18+00:00)
Title: Fix of reconnect() method + 'passive' queues.

Hello,
I am using node-amqp through a proxy and I figured out two issues. The issues are due to the timeout of the proxy, which closes the connection.

The first issue is about the `reconnect()` method: When the proxy closes the connection, I receive a 'close' event. I wanted to reconnect manually using the `reconnect()` method (otherwise I need to wait until an error occurs to fall in the `backoff()` method), but in this method, the queues' subscriptions are not marked as closed, unlike in the `backoff()` method.
Thus, the queues will never resubscribe once we are reconnected.

The second issue is about the passive queues. Before sending a message, I want to declare a 'passive' queue, in order to check if it exists and if it has consumers.
But by doing that, we have two issues:
- the passive queue will override the reference of the active queue in the `Connection.queues` array. Then, if we reconnect, the active queue will not be able to resubscribe as amqp does not have any reference on its `consumerTagListeners` anymore.
- this will open a new channel for each passive queue, which will never be closed. So here I close it immediately after having received the declare-ok response.

The attached patch has resolved these issues in my env, but my amqp knowledge is not huge so I'd like you to have a look and tell me if it seems good to you.

Thanks.