Declare RabbitMQ exchange before publishing messages#9393
Open
ittennull wants to merge 1 commit intoChilliCream:mainfrom
Open
Declare RabbitMQ exchange before publishing messages#9393ittennull wants to merge 1 commit intoChilliCream:mainfrom
ittennull wants to merge 1 commit intoChilliCream:mainfrom
Conversation
RabbitMQ requres an exchange to exist, otherwise it returns an error and the whole channel becomes unusable. The code uses ConcurrentDictionary to remember which exchanges were declared. It is faster than calling the function before each publish.
michaelstaib
requested changes
Mar 19, 2026
Member
michaelstaib
left a comment
There was a problem hiding this comment.
This actually introduces more issues to the implementation and also introduces channel handling that is explicitly called our in the RabbitMQ docs to not do.
We will do a general review of the subscription providers after 16 is out.
Contributor
Author
|
Could you elaborate: what problems does it introduce and what exactly is advised not to do in the docs? |
Contributor
Author
If I know what you mean, I can probably fix it |
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.
RabbitMQ requires an exchange to exist in order to publish a message to it, otherwise it returns an error and the whole channel becomes unusable. The code uses ConcurrentDictionary to remember which exchanges were declared. It is faster than calling the function before each publish.
The problem that this PR fixes appears when an application starts publishing updates to graphql subscription before a client connects to it. Since the queue and the exchange were created only on consumer side, the producer always failed if it was too fast because it couldn't publish to a non-existent exchange. Even worse - the whole channel got closed and all consumers and producers, even those that had create-first-publish-second approach, started to fail.