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.
Title: Issue with Shared Queue Across Multiple Subscribers
Description:
Hello Maintainers,
While using the library, I encountered an unexpected behaviour when running multiple subscriber instances with a shared queue. Specifically, when publishing a single message, only one of the subscribers receives it, even though all subscribers have similar bindings. After running the publisher multiple times, each subscriber eventually receives the message, suggesting a round-robin distribution due to the shared queue.
Steps to Reproduce:
Set up three subscriber instances with the following binding keys: "#", "kern.", and ".critical".
Run a publisher to send a message with the routing key "app.info".
Observe that only one subscriber receives the message. Running the publisher multiple times results in each subscriber eventually receiving the message.
Expected Behavior:
All subscribers with matching binding keys should receive the message on the first publish.
Actual Behavior:
Only one subscriber receives the message at a time due to the shared queue.
Proposed Solution:
After some investigation, I found that giving each subscriber instance its own unique queue (by setting
exclusive=True
during queue declaration and removing the queue nametask_queue
) resolved the issue. I've attached the modified code in this PR for reference. The code generates a new queue that is persistent as intended earlier for each instance of the script.Would appreciate any feedback or insights into whether this is the intended behavior, and if the proposed solution aligns with the library's design principles.
Thank you for your time and consideration!