-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Messenger][Sqs] Add SQS fair queues support #62080
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.1
Are you sure you want to change the base?
Conversation
|
Hey! I see that this is your first PR. That is great! Welcome! Symfony has a contribution guide which I suggest you to read. In short:
Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change. When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor! I am going to sit back now and wait for the reviews. Cheers! Carsonbot |
647513b to
606e30d
Compare
|
Branch rebased, commits squashed. |
606e30d to
af21de9
Compare
|
Rebased. Still waiting for review |
src/Symfony/Component/Messenger/Bridge/AmazonSqs/Transport/AmazonSqsFairQueueStamp.php
Outdated
Show resolved
Hide resolved
|
Hi @Greg0 ! Is there a chance for you to target 6.4? Thanks and have a good day! |
|
@GrzegorzDrozd AFAIR features can be proposed only for future releases. That one will target probably nearest v8.1 7.4 and 8.0 are in RC stage |
What if we threat this as a bug. In fact code prevents you from sending message using a fair queue mechanism. |
I would say code just not supports it instead of supporting it in wrong way (bug). AWS introduced that in Q2 2025 so it's new feature in SQS itself. Docs about contributing describes clearly what is what. There is always possibility of forking messenger SQS lib and applying such changes in private scope. |
8aa703e to
4a92031
Compare
|
Symfony docs update |
4a92031 to
28f9e03
Compare
stof
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether we should throw an exception when both the Fifo and Fair stamps are set instead of silently ignoring the Fair stamp.
And the readme of the bridge should document that bridge-specific stamp (symfony-docs currently does not have dedicated documentation pages for each platform bridge)
| $messageDeduplicationId = $amazonSqsFifoStamp->getMessageDeduplicationId(); | ||
| } | ||
|
|
||
| /** @var AmazonSqsFairQueueStamp|null $amazonSqsFairQueueStamp */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not needed. The generic types on the last method already infer the same type for that variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, removed
Would you like me to place change that will throw exception in that specific case? I do not have strong arguments to follow any of proposed paths (silent ignore or exception throwing). Exception make sense because it's not expected to use that both stamps and the same time. |
|
@stof Actually, after thinking about this more carefully, I believe keeping the silent precedence is the better approach. This creates a practical conflict: if we throw an exception when both stamps are present, it would force developers to add complex conditional logic in their middleware to check queue types before adding the fair queue stamp. This is particularly problematic because:
The current behavior (FIFO taking precedence) is actually the correct AWS behavior - FIFO queues already guarantee ordering and uses the same If we want to be more explicit, we could:
But throwing an exception would make the feature harder to use in real-world scenarios where automatic stamp application is needed. What do you think? |
@stof I've updated bridge readme |
What it does and why it's needed
This PR adds support for AWS SQS fair queues by introducing a new
AmazonSqsFairQueueStamp. Fair queues allow messages to be processed fairly across multiple message groups without requiring a FIFO queue, which is useful for multi-tenant applications where you want to prevent one tenant from monopolizing queue processing.According to the AWS SQS fair queues documentation, you can achieve fair processing in standard queues by setting the
MessageGroupIdparameter without converting to a FIFO queue.How it works
Add the
AmazonSqsFairQueueStampto your message envelope with a tenant/group identifier:The stamp sets the
MessageGroupIdparameter on standard SQS queues, enabling fair message distribution across different message groups without the overhead of FIFO queues.Important notes
AmazonSqsFairQueueStamponly works on standard queues (not FIFO)AmazonSqsFifoStampandAmazonSqsFairQueueStampare present, the FIFO stamp takes precedenceChanges
AmazonSqsFairQueueStampclassAmazonSqsSenderto handle the fair queue stampConnectionto supportMessageGroupIdon standard queues