postwait / node-amqp

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

Support for connection.blocked #342

Closed albert-lacki closed 9 years ago

albert-lacki commented 10 years ago

I have added support for blocked connection notifications (http://www.rabbitmq.com/connection-blocked.html)

1) When server sends connection.blocked / connection.unblocked an event is emited by Connection object, and the information about being blocked is saved. 2) When someone try to publish to an exchange through blocked connection and callback is provided it returns an error.

I'm not sure if the test case I provided is ok for you, because the only way (AFAIK) to easily simulate desired state is to set vm_memory_high_watermark to 0 using rabbitmqctl. Although it proves that both above works, it might be problematic for someone (or travis etc.) to use rabbitmqctl which often needs root account.

More, if you don't want publishers to fail with error when connection is blocked it is still good for me just to have event emitted from Connection object.