Conversation
|
Yes, garbage-collecting exchanges is a pain. I haven't come up with a good solution -- it's a gap in AMQP, really. The flaw in this change is that it only takes into account subscribers -- when the last subscriber goes, the exchange will be deleted, and any publishers to that exchange will get an error and crash. See #49 re garbage collection in general. |
To explain the problem a bit more: if an exchange is marked as auto-delete, once no queues are bound to it, it will be deleted. In rabbit.js, queues are owned by subscribers, so in effect what you get is that once there are no subscribers, there are no queues, and once there are no queues, the exchange is deleted. However, there's no analogue to those queues for publishers, so there's no way (that I've come up with) for a publisher to prevent an auto-delete exchange from being deleted. Without that, while this might help keep things tidy, it also causes problems. |
I use rabbit.js with socket.io this way: when connection (between browser and nodejs) open it creates it's own unique SubSocket so backend can publish messages directly client.
If flag autoDelete set to false rabbitMq keeps all of this unique (and already useless) exchanges after socket.io closes connection and it's count grow to hundreds, that is at least annoying.