Detect deleted rabbitMQ queues and re-declare them#838
Open
LincolnPuzey wants to merge 5 commits intoBogdanp:masterfrom
Open
Detect deleted rabbitMQ queues and re-declare them#838LincolnPuzey wants to merge 5 commits intoBogdanp:masterfrom
LincolnPuzey wants to merge 5 commits intoBogdanp:masterfrom
Conversation
8def4c3 to
62cea58
Compare
Previously this fix relied on the canonical queue being declared before the delayed one. If for some reason the delayed queue is declared first, then the delayed queue name would get added to self.queues. This commit fixes it so this doesn't happen. Only the canonical queue name is ever added to self.queues. This commit also makes it more obvious that only canonical queue names should be stored in self.queues and self.queues_pending by adding some comments and renaming the arg to _ensure_queue.
This commit splits the existing test which didn't work, into two tests. One for the consumer side, and one for the publishing side. This ensures they don't interfere with each other. Currently both fail, actual fixes should be in the next commits.
So that they are re-declared and the message is successfully published. In order to detect a missing queue on publish you must (1) enable `confirm_delivery` and (2) publish message with the `mandatory` flag. This commit sets the `mandatory` flag, and then checks for the `UnroutableError` raised as a result. The old implementation checking for `reply_code` was wrong. `reply_code` is only present on Connection/Channel close errors. These never happen when publishing to a non-existent queue, the Connection and Channel is not closed.
Instead of removing the queue from `self.queues`, which causes before/after declare_queue middleware hooks to be called, add the queue to `self.pending_queues` which just causes it to be re-declared inside rabbitMQ.
When consuming from a declared queue, and it is missing in rabbitMQ, mark it as a "pending" queue so it is re-declared when the consumer restarts. This requires passing the whole Broker object to the ConsumerThread, not just parameters.
Collaborator
Author
|
Hi @synweap15 @karolinepauls @Bogdanp This is making some changes in the RabbitMQ broker. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #832
This PR ensures that queues are re-declared if they are deleted while rabbitMQ is running.
It detects missing queues in two places:
reply_code==404will be raised. This is now checked in the consumer.confirm_deliveryis turned on. When this is the case, themandatoryflag is set, which causes anUnroutableErrorto be raised. This is checked for.In both cases the missing queue is re-added to
queues_pending. This causes it to be re-declared the next time_ensure_queueis called.