-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Comply with Amazon SQS requirements for message body #54920
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
Conversation
VincentLanglet
commented
May 14, 2024
Q | A |
---|---|
Branch? | 5.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Issues | Fix #49844 |
License | MIT |
f61a786
to
b1f0c65
Compare
are failing because they are using
and not the PhpSerializer were I added And fabbot.io is failing with unrelated changes. |
src/Symfony/Component/Messenger/Transport/Serialization/PhpSerializer.php
Outdated
Show resolved
Hide resolved
9b7f731
to
48b3af7
Compare
@@ -1332,6 +1333,10 @@ private function addWebLinkSection(ArrayNodeDefinition $rootNode, callable $enab | |||
|
|||
private function addMessengerSection(ArrayNodeDefinition $rootNode, callable $enableIfStandalone) | |||
{ | |||
$defaultSerializer = class_exists(AmazonSqsSerializer::class) |
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.
Hum, I missed this part: changing the serializer service for all transports.
I don't think that's the correct approach.
Instead, I see two ways:
- patch the native serializer
- fix the encoding in AmazonSqsSender, just after
$encodedMessage = $this->serializer->encode($envelope);
Option 2. looks the most appropriate to me.
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.
Yeah, I wasn't sure about the best strategy for this.
The solution 1 leads to an impact for all the user of PHPSerializer even if they don't use AmazonSQS. There is no reason to follow AmazonSQS needs if you don't use it (so I tried to follow #49844 (comment))
The solution 2 looks interesting, but if I add an extra base64_encode call after $encodedMessage = $this->serializer->encode($envelope);
, how can I be sure it will be decoded by the serializer (since any custom Serializer can be used) ?
So I thought changing the defaut serializer was the right way for AmazonSqs users.
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.
The solution 2 looks interesting, but if I add an extra base64_encode call, how can I be sure it will be decoded by the serializer (since any custom Serializer can be used) ?
If a custom serializer is used, it has to comply with Amazon's requirements, so this extra logic we're talking about shouldn't be triggered.
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 could add a Header to tell AmazonSqsReceiver it require an extra base64_decode.
WDYT @nicolas-grekas should I add the commit: https://github.com/VincentLanglet/symfony/compare/amazonSerializer...VincentLanglet:symfony:amazonSerializer-2?expand=1 or should I let the PR like this ?
d54eb90
to
a1a6e79
Compare
Do you have time for a new review @OskarStark @nicolas-grekas ? Thanks a lot. |
Thank you @VincentLanglet. |