In the official RabbitMQ AMQP client, there is no concept of a controlling process common in Erlang systems. Thus, if you create a Connection, a Channel or a Consumer, there is no guarantee that it will be closed if the process creating it goes away.
In other words: you have to treat those resources as unmanaged and handle them accordingly.
Turtle currently does not manage resources at all. This leads to situations in which channels and consumers end up in a "limbo" state:
They still exist and the AMQP server believes they are there.
The server has already sent messages to the client (via prefetch)
The consumer process has already forwarded the messages to the mailbox of the subscribed process.
That process is dead, so the messages are gone. Forever.
In this situation, the messages is seen as delivered and they are then being "processed" by the client. But since they are gone, they are unlikely to ever be acked, unless one issues a faulty bulk-ack or bulk-reject by accident. Everything is dire.
This PR introduces a new gen_server in turtle called the janitor. The responsibility of the janitor is to keep track of resources and monitor processes. If a process goes away, the resources belonging to that process is also going to go away since the janitor will clean up.
Now, the only process which needs to trap exits is the janitor. And a lot of nasty termination paths can be removed from turtle. In short, we'll get a far more stable version of turtle. The downside is that this is a backwards compatibility breaking change.
In the official RabbitMQ AMQP client, there is no concept of a controlling process common in Erlang systems. Thus, if you create a Connection, a Channel or a Consumer, there is no guarantee that it will be closed if the process creating it goes away.
In other words: you have to treat those resources as unmanaged and handle them accordingly.
Turtle currently does not manage resources at all. This leads to situations in which channels and consumers end up in a "limbo" state:
In this situation, the messages is seen as delivered and they are then being "processed" by the client. But since they are gone, they are unlikely to ever be acked, unless one issues a faulty bulk-ack or bulk-reject by accident. Everything is dire.
This PR introduces a new
gen_server
in turtle called thejanitor
. The responsibility of the janitor is to keep track of resources and monitor processes. If a process goes away, the resources belonging to that process is also going to go away since the janitor will clean up.Now, the only process which needs to trap exits is the
janitor
. And a lot of nasty termination paths can be removed from turtle. In short, we'll get a far more stable version ofturtle
. The downside is that this is a backwards compatibility breaking change.