[Messenger] Extract the failed-message logic out of the console commands - #66002
Open
nicolas-grekas wants to merge 1 commit into
Open
[Messenger] Extract the failed-message logic out of the console commands#66002nicolas-grekas wants to merge 1 commit into
nicolas-grekas wants to merge 1 commit into
Conversation
The listing, inspection and removal of failed messages lived inside AbstractFailedMessagesCommand, mixed with console input parsing and rendering, so a web UI had to reimplement it. FailedMessageRepository now holds the transport-facing half and FailedMessageFilter the class and failure-time selection. The commands keep their options, their rendering and their confirmations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
AbstractFailedMessagesCommandmixes three concerns: transport-facing logic that has nothing to do with the console, console input parsing, and rendering. Only the first is what a web UI or any other non-console caller needs, and today it can only be reached by extending an@internalcommand.This extracts that first group:
FailedMessageRepositoryresolves the failure transports and exposesgetTransportNames(),count(),supportsListing(),find(),all(),remove()andredispatch(). It is registered asmessenger.failed_message_repositoryand aliased for autowiring, so a controller can inject it directly. It is removed from the container when no failure transport is configured.FailedMessageFilteris the class-name and failure-time selection thatmatchesFilter()used to implement, as a value object with amatches()method.The commands keep their options, their rendering, their confirmations and their exact output. The net effect on the existing files is 206 lines removed for 154 added.
Answers to the three questions raised in the issue:
Retry stays out.
messenger:failed:retrydoes not simply redispatch: it builds a realWorker, wires event listeners and handles signals, and for the by-id path it wraps each envelope in aSingleMessageReceiverso the ack goes to the wrapper rather than to the failure transport. Extracting that means deciding what a non-console caller gets in place of the worker loop, which is a design question of its own.FailedMessageRepository::redispatch()does exist, because for a listable transport it is a dispatch plus an ack and needs no worker, but the command keeps its own flow and both paths now shareprepareForRedispatch()so the stamp stripping has a single definition.No delegation shims.
AbstractFailedMessagesCommandis marked@internal, so the methods that moved (getMessageIdsByFilter(),matchesFilter(),getReceiver(),getMessageId()) are removed rather than kept as delegations, andgetFilters()becomesgetFilter()returning the value object. Constructor signatures are untouched, so anything instantiating the concrete commands keeps working.Location. A new
Symfony\Component\Messenger\Failure\namespace, alongside the existingRetry\andExecution\.The API is michaelthieulin's proposal from the issue thread, with
remove()taking anEnveloperather than an id so that removing every message does not re-find()each one.