Greetings,
I was investigating an issue in a RabbitMQ plugin I maintain:
https://github.com/noxdafox/rabbitmq-message-deduplicationWhen restarting the broker, all declared deduplication queues do not behave as such any more.
Deduplication queues implement the `rabbit_backing_queue` behaviour adding the deduplication functionality through the `is_duplicate` callback.
Similarly as for priority queues, the plugin installs a boot-step which overrides the `backing_queue_module` application environment variable at startup.
When the broker is restarted, all existing queues are initialized before the plugin. Therefore, the deduplication queues will adopt the `rabbit_variable_queue` module instead of the `rabbit_message_deduplication_queue` one.
It took me some time to realize plugins are loaded as last components. As a consequence, even if they hook to the correct boot step, they won't be initialized during such. Hence, the erroneous behaviour described above.
Currently, I developed a workaround which restarts all the deduplication queue processes when the plugin is started. In this way, I ensure the correct `backing_queue_module` is adopted.
Nevertheless, I dislike this approach as:
* It pokes into the broker internal supervisor hierarchy
* It generates misleading error messages in the logs while restarting the queues
* It can significantly slow down the broker startup as queues are recovered twice
* It might cause undesirable side effects
The main question is if there's a better way to fix this particular issue. One approach, for example, would be to notify the queue process of its correct `backing_queue_module` when initializing the plugin.
The second thing I wanted to ask is what is the difference from a plugin development perspective between installing a boot step and the implementation of the Application behaviour.
If plugins initialization are executed last, their boot dependency declaration will be always ignored (the `enables` statement).
For example, the RabbitMQ MGMT application plugin enables the `empty_db_check` boot step, most of the exchange type plugins enable `kernel_ready`. Even if these steps are executed way before the plugins boot steps are executed.
Yet most of the plugins seem to install their boot steps nevertheless.
What is I am missing or misunderstanding?
Kind regards,
Matteo.