-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Messenger] Requeue of a possibly mutated message on failure #36735
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
Comments
Hey, thanks for your report! |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Hey, I didn't hear anything so I'm going to close it. Feel free to comment if this is still relevant, I can always reopen! |
There is a real case related to this issue. When an email is sent through the messenger using alternative mail transport and if this mail transport fails then modified email is pushed to the queue for the next try (without X-Transport header). The second try takes default mail transport whether you want it or not. In this case I believe the method \Symfony\Component\Mailer\Transport\Transports::send should clone a message before modifying and sending it. |
@carsonbot this is still relevant |
I've created a separate issue for the email case: #44741 |
Would you mind sending a PR to the doc @Nommyde or @tjveldhuizen? |
Do we know situations in which mutability of the message should be qualified as a feature? Or is it always a bad idea? I think that's also relevant for the kind of addition to the docs. |
I don't think there is any case where mutability of the message is legit. |
I don't see what we can fix here. |
Let's close this old issue because it looks like the latest consensus is that we can't/shouldn't do more changes about this. Thanks. |
Symfony version(s) affected: 4.4, 5.*
Description
When an exception occurs during handling a message, it is requeued following the (default or specific) configuration. In my opinion the message (except from extra stamps on the envelope) should be the same as the original message.
However, when the message object is mutated during handling, the modified message is serialized again before requeueing happens.
How to reproduce
https://github.com/tjveldhuizen/symfony-mutable-message-reproducer
In message 9, the ArrayCollection contains no elements anymore.
In message 10, the content has four (original + 3 retries) exclamation marks added.
Possible Solution
I think modifying the message is bad practice, however (as shown with the ArrayCollection) might happen unnoticed. It took a lot of time to figure out what was happening, so at least some prevention would be appreciated. The easiest being to state in the documentation that a message should be designed being immutable.
The text was updated successfully, but these errors were encountered: