-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Messenger multiple failed transports #38468
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
Messenger multiple failed transports #38468
Conversation
c9bd097
to
bcb3783
Compare
@weaverryan i have removed some of the tests because of merging conflicts.. since this is still being changed a lot... after we agree on an implementation it’s easy to fix them. |
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
@weaverryan I just uploaded a working version of your proposal. Feel free to review, before I do the tests. Thanks! |
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.
Getting close...
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Resources/config/console.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
Waiting for Ryan to help me.
He has been reviewing my PR since the beginning.
Let me talk with him, to see what can we do.
Thanks for pinging.
…On Thu, Dec 31, 2020 at 9:04 AM Kamil Ścisłowski ***@***.***> wrote:
How long it will take to be merged into master? @monteiro
<https://github.com/monteiro> are you still working on it? :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#38468 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAASFW36LHEU3O7E3DDWKWTSXQ5ANANCNFSM4SHURUVA>
.
|
Sure, I've deleted previous comment because I wasn't sure if it's appropriate place to ask :) But I appreciate for answering. For me and I see that not only for me it's really important feature that is missing from core. |
@escees no worries. I already talked with @weaverryan to help me during this 2021 to merge this missing feature. |
Fingers crossed for this to be completed and merged :) |
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.
Thanks for you work on this - we're getting ever close - so many little details :)
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/DependencyInjection/MessengerPass.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php
Outdated
Show resolved
Hide resolved
b2cc3f6
to
303514e
Compare
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
@weaverryan I have done all changes, including fixing all the tests:
which I don't know how to fix, related to that weird extra parameter code in https://github.com/symfony/symfony/pull/38468/files#diff-9213ec846d94497cc34a4b922373cb52e0d53015604427a4aec0661289c58ac8R177
|
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.
EDIT
The below issue is NOT an issue. It's caused by the retry commands being allowed to query the wrong transport. Basically, the fix in #40588 closes this possibility. There is no problem here.
I've been playing with this, and it's looking really good - it's close.
But I just hit one major problem. Suppose this setup"
framework:
messenger:
failure_transport: failure_transport1
transports:
transport2:
dsn: doctrine://default
options:
queue_name: transport2
failure_transport: failure_transport2
failure_transport1:
dsn: doctrine://default
options:
queue_name: failure_transport1
failure_transport2:
dsn: doctrine://default
options:
queue_name: failure_transport2
routing:
App\Message\ILikeToFail: transport2
The ILikeToFail
fail message is routed to transport2
. So if it fails, it is sent to failure_transport2
. Great! Now, if I retry that message from failure_transport2
and it fails, it is sent to failure_transport1
. That is not correct.
It makes sense why it's doing this. failure_transport2
is a normal transport. So when the message fails, it actually looks at its own "failure transport" config and determines that the message should go to the "global failure transport", which is failure_transport1
. But I don't think this is the behavior we want: the message should go back to failure_transport2
after failing. That is THIS message's failure transport, and it should remain here until it is successful or removed because it hits the retry limit.
tl;dr We need a way to respect the original failure transport that message was routed to. We probably need (if we don't have this already) a stamp to save the "failure transport name" onto a message, so it can be read when being re-delivered after the messages fails a retry from the failure queue.
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php
Outdated
Show resolved
Hide resolved
@@ -122,10 +129,10 @@ private function listMessages(SymfonyStyle $io, int $max) | |||
$io->comment('Run <comment>messenger:failed:show {id} -vv</comment> to see message details.'); |
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 line (and a few other ones in this command... and maybe other commands, like:retry
and :remove
) now needs to include --failure-transport=
if that option was passed. Otherwise, you will be looking for the message in the wrong transport.
Btw, with Doctrine as your failure transport, forgetting the --failure-transport=
option actually DOES work... but due to a bug I just discovered (that we should fix, in a different PR). The find()
method in the Doctrine connection class incorrectly does NOT include the AND queue_name = ?
part.
symfony/src/Symfony/Component/Messenger/Bridge/Doctrine/Transport/Connection.php
Lines 278 to 281 in 2da27bb
public function find($id): ?array | |
{ | |
$queryBuilder = $this->createQueryBuilder() | |
->where('m.id = ?'); |
src/Symfony/Component/Messenger/Command/FailedMessagesRetryCommand.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/FailedMessagesShowCommand.php
Outdated
Show resolved
Hide resolved
Pending to fix the console command tests after adding the list of transports and the warning. |
c14fa3d
to
336c9b6
Compare
…ransport (monteiro) This PR was merged into the 4.4 branch. Discussion ---------- add missing queue_name to find(id) in doctrine messenger transport | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | License | MIT This bug was noticed by @weaverryan when reviewing the PR: #38468 related to multiple failure transports. Commits ------- bb26a92 add missing queue_name to find(id) in doctrine messenger transport
src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php
Show resolved
Hide resolved
src/Symfony/Component/Messenger/EventListener/SendFailedMessageToFailureTransportListener.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/Messenger/Command/AbstractFailedMessagesCommand.php
Outdated
Show resolved
Hide resolved
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.
Great work. Some comments above
Thanks @chalasr. Already fixed with your suggestions. |
605fc7b
to
5810b6c
Compare
It took time, but here we go, this is in now. Thank you very much @monteiro. |
Thanks @chalasr again! |
…sCommand (nicolas-grekas) This PR was merged into the 5.3-dev branch. Discussion ---------- [Messenger] fix deprecation layer in AbstractFailedMessagesCommand | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - Added in #38468, spotted in #40643 Commits ------- 079cb31 [Messenger] fix deprecation layer in AbstractFailedMessagesCommand
This PR was squashed before being merged into the 5.3-dev branch. Discussion ---------- [Messenger] Multiple failed transports <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> ### New Feature: Messenger: Multiple Failure Transports Transports closes #15168 This PR adds the documentation related to PR: symfony/symfony#38468 What it needs to be clear in the documentation: - You can define multiple transports, one per transport (instead of the global one, as it is supported today) - If you don't define a global failure transport and if the transport does not have the `failure_transport` configured the messages will be discarded - If you define both a global and at the transport level, the `failure_transport` configuration, the one taken into account is at the transport level configuration. - The failed commands have an option argument to specify the transport level `--transport`. Without arguments is the global failed transport taken into account. Commits ------- d784895 [Messenger] Multiple failed transports
…tence alias being used (monteiro) This PR was squashed before being merged into the 5.3 branch. Discussion ---------- [Messenger] fix BC for FrameworkBundle 4.4 with a non-existence alias being used | Q | A | ------------- | --- | Branch? | 5.3 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | Fix #41545 ... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT When trying to update symfony/messenger to 5.3 while still using symfony/framework-bundle 4.4 there is an error: The service "console.command.messenger_failed_messages_retry" has a dependency on a non-existent service "messenger.failure_transports.default". This is because in Symfony Messenger 5.3, on the PR #38468 to support multiple failure transports we have created an alias, that is only available on the FrameworkBundle 5.3. This fix will use an already existence alias. Sample project to test this behavior: https://github.com/monteiro/PR-41553-symfony Commits ------- aa0e166 [Messenger] fix BC for FrameworkBundle 4.4 with a non-existence alias being used
Strategy applied
SendFailedMessageToFailureTransportListener
. This way we re-use the same listener.Configuration example
You can test this feature easily on a demo project. Just follow the README.
More information on issue #34911
What needs to be done so this can be merged: