Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Messenger] Be able to get raw data when a message in not decodable by the PHP Serializer#39622

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:6.2fromlyrixx:messenger-and-class-moved
Sep 1, 2022

Conversation

@lyrixx
Copy link
Member

@lyrixxlyrixx commentedDec 23, 2020
edited
Loading

QA
Branch?6.2
Bug fix?yes
New feature?yes
Deprecations?no
Tickets
LicenseMIT
Doc PR

It's easier to review the pr with?w=1


Why?

This PR aimed to handle properly messaged that are already failed and alsonot decodable anymore.

This use case occurs when a Message class is renamed / moved to another namespace

Reproducer

  1. Publish many message of typeApp\Message\Foobar
  2. Consume them all, but throw an Exception exception in the handler
  3. RenamedFoobar toFoo

Before / After

commandmessenger:failed:show

Before

Without an ID
…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:showThere are 94 messages pending in the failure transport.In PhpSerializer.php line 84:  Message class "App\Message\Foobar" not found during decoding.messenger:failed:show [--max MAX] [--transport [TRANSPORT]] [--stats] [--class-filter CLASS-FILTER] [--] [<id>]

And thismessage is lost

With an ID
>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:show 68There are 93 messages pending in the failure transport.In PhpSerializer.php line 84:  Message class "App\Message\Foobar" not found during decoding.messenger:failed:show [--max MAX] [--transport [TRANSPORT]] [--stats] [--class-filter CLASS-FILTER] [--] [<id>]

Message lost too

After

Without an ID
>…goire/dev/labs/symfony/symfony-5.2(remaned) bin/console  messenger:failed:showThere are 94 messages pending in the failure transport. ----- ------------------------ --------------------- ---------------------------------------  Id    Class                    Failed at             Error ----- ------------------------ --------------------- ---------------------------------------  62    __PHP_Incomplete_Class   2022-08-12 16:26:06   FoobarHandler is not implemented yet.  63    __PHP_Incomplete_Class   2022-08-12 16:26:06   FoobarHandler is not implemented yet.  64    __PHP_Incomplete_Class   2022-08-12 16:26:06   FoobarHandler is not implemented yet. // Showing first 50 messages. // Run messenger:failed:show {id} --transport=failed -vv to see message details.

No messages are lost

With an ID
>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:show 69There are 92 messages pending in the failure transport.Failed Message Details====================== ------------- ---------------------------------------  Class         __PHP_Incomplete_Class  Message Id    69  Failed at     2022-08-12 16:26:06  Error         FoobarHandler is not implemented yet.  Error Code    0  Error Class   Exception  Transport     async ------------- --------------------------------------- Message history:  * Message failed at 2022-08-12 16:25:58 and was redelivered  * Message failed at 2022-08-12 16:25:59 and was redelivered  * Message failed at 2022-08-12 16:26:02 and was redelivered  * Message failed at 2022-08-12 16:26:06 and was redelivered [ERROR] The message could not be decoded. Re-run command with -vv to see more message & error details. Run messenger:failed:retry 69 --transport=failed to retry this message. Run messenger:failed:remove 69 --transport=failed to delete it.

messages not lost

With an ID an -vv
>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:show 69 -vvThere are 92 messages pending in the failure transport.Failed Message Details====================== ------------- ---------------------------------------  Class         __PHP_Incomplete_Class  Message Id    69  Failed at     2022-08-12 16:26:06  Error         FoobarHandler is not implemented yet.  Error Code    0  Error Class   Exception  Transport     async ------------- --------------------------------------- Message history:  * Message failed at 2022-08-12 16:25:58 and was redelivered  * Message failed at 2022-08-12 16:25:59 and was redelivered  * Message failed at 2022-08-12 16:26:02 and was redelivered  * Message failed at 2022-08-12 16:26:06 and was redeliveredMessage:======== [ERROR] The message could not be decoded. See below an APPROXIMATIVE representation of the class.__PHP_Incomplete_Class(App\Message\Foobar) {}Exception:==========Exception^ {  message: "FoobarHandler is not implemented yet."  code: 0  file: "/home/gregoire/dev/labs/symfony/messenger-class-not-found/src/MessageHandler/FoobarHandler.php"  line: 12  trace: {    /home/gregoire/dev/labs/symfony/messenger-class-not-found/src/MessageHandler/FoobarHandler.php:12    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/HandleMessageMiddleware.php:95 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/SendMessageMiddleware.php:71 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/FailedMessageProcessingMiddleware.php:34 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/DispatchAfterCurrentBusMiddleware.php:68 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/RejectRedeliveredMessageMiddleware.php:41 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/AddBusNameStampMiddleware.php:37 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Middleware/TraceableMiddleware.php:43 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/MessageBus.php:73 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/TraceableMessageBus.php:41 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/RoutableMessageBus.php:54 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Worker.php:156 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Worker.php:105 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Messenger/Command/ConsumeMessagesCommand.php:223 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Console/Command/Command.php:309 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Console/Application.php:1019 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:94 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Console/Application.php:300 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:80 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Console/Application.php:172 { …}    /home/gregoire/dev/github.com/lyrixx/symfony/src/Symfony/Component/Runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}    ./vendor/autoload_runtime.php:29 { …}    ./bin/console:11 { …}  }} Run messenger:failed:retry 69 --transport=failed to retry this message. Run messenger:failed:remove 69 --transport=failed to delete it.
screenshot with colors

screenshot with colors

messages not lost

commandmessenger:failed:retry

Before

>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:retry 69 // Quit this command with CONTROL-C. // Re-run the command with a -vv option to see logs about consumed messages.There are 92 messages pending in the failure transport.To retry all the messages, run messenger:consume failedIn PhpSerializer.php line 84:  Message class "App\Message\Foobar" not found during decoding.messenger:failed:retry [--force] [--transport [TRANSPORT]] [--] [<id>...]

And the first message is lost

Same if I use an ID

After

Without ID
>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:retry // Quit this command with CONTROL-C. // Re-run the command with a -vv option to see logs about consumed messages.There are 91 messages pending in the failure transport.To retry all the messages, run messenger:consume failedFailed Message Details====================== ------------- ---------------------------------------  Class         __PHP_Incomplete_Class  Message Id    63  Failed at     2022-08-12 16:26:06  Error         FoobarHandler is not implemented yet.  Error Code    0  Error Class   Exception  Transport     async ------------- --------------------------------------- Message history:  * Message failed at 2022-08-12 16:25:58 and was redelivered  * Message failed at 2022-08-12 16:25:59 and was redelivered  * Message failed at 2022-08-12 16:26:02 and was redelivered  * Message failed at 2022-08-12 16:26:06 and was redelivered [ERROR] The message could not be decoded. Re-run command with -vv to see more message & error details.In FailedMessagesRetryCommand.php line 176:  The message with id "63" could not decoded, it can only be shown or removed.messenger:failed:retry [--force] [--transport [TRANSPORT]] [--] [<id>...]

And the message is not lost

With an ID
>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:retry  63 // Quit this command with CONTROL-C. // Re-run the command with a -vv option to see logs about consumed messages.There are 91 messages pending in the failure transport.To retry all the messages, run messenger:consume failedFailed Message Details====================== ------------- ---------------------------------------  Class         __PHP_Incomplete_Class  Message Id    63  Failed at     2022-08-12 16:26:06  Error         FoobarHandler is not implemented yet.  Error Code    0  Error Class   Exception  Transport     async ------------- --------------------------------------- Message history:  * Message failed at 2022-08-12 16:25:58 and was redelivered  * Message failed at 2022-08-12 16:25:59 and was redelivered  * Message failed at 2022-08-12 16:26:02 and was redelivered  * Message failed at 2022-08-12 16:26:06 and was redelivered [ERROR] The message could not be decoded. Re-run command with -vv to see more message & error details.In FailedMessagesRetryCommand.php line 176:  The message with id "63" could not decoded, it can only be shown or removed.messenger:failed:retry [--force] [--transport [TRANSPORT]] [--] [<id>...]

commandmessenger:failed:remove

Before

>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:remove  63In PhpSerializer.php line 84:  Message class "App\Message\Foobar" not found during decoding.messenger:failed:remove [--force] [--transport [TRANSPORT]] [--show-messages] [--] <id>...

The message is lost, but it's not an issue I guess :p

After

>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:remove  69 [ERROR] The message with id "69" was not found.>…abs/symfony/messenger-class-not-found(new) bin/console  messenger:failed:remove  79Failed Message Details====================== ------------- ---------------------------------------  Class         __PHP_Incomplete_Class  Message Id    79  Failed at     2022-08-12 16:26:06  Error         FoobarHandler is not implemented yet.  Error Code    0  Error Class   Exception  Transport     async ------------- --------------------------------------- Message history:  * Message failed at 2022-08-12 16:25:58 and was redelivered  * Message failed at 2022-08-12 16:25:59 and was redelivered  * Message failed at 2022-08-12 16:26:02 and was redelivered  * Message failed at 2022-08-12 16:26:06 and was redelivered [ERROR] The message could not be decoded. Re-run command with -vv to see more message & error details. Do you want to permanently remove this message? (yes/no) [no]: > yes [OK] Message with id 79 removed.

Extra

messenger:consume command

This command is not fixed on purpose: We keep the default behavior to keep a BC.

BUT I would like to use the same stamp system I introduce to avoid loosing a message.
Because ATM, when a DecodeException is thrown, the message is lost. Not cool!

>…goire/dev/labs/symfony/symfony-5.2(remaned) bin/console  messenger:consume failed [OK] Consuming messages from transports "failed". // The worker will automatically exit once it has received a stop signal via the messenger:stop-workers command. // Quit the worker with CONTROL-C. // Re-run the command with a -vv option to see logs about consumed messages.In PhpSerializer.php line 92:  Message class "App\Message\Foobar" not found during decoding.

Koc, OskarStark, maxhelias, jeroennoten, chapterjason, and ismail1432 reacted with thumbs up emoji
@lyrixxlyrixxforce-pushed themessenger-and-class-moved branch fromca0627b to25ce8d1CompareDecember 23, 2020 18:01
@nicolas-grekasnicolas-grekas added this to the5.x milestoneDec 28, 2020
@lyrixx
Copy link
MemberAuthor

ping @symfony/mergers : What do you think about this PR? IMHO this is really needed to be able to explore "dead" messages.

And what do you think about the newMessageDecodingFailedStamp class. IMHO, this is cleaner than before and more flexible.

Should I address comments and add some tests, or we gonna close it anyway?

OskarStark reacted with thumbs up emoji

@maxhelias
Copy link
Contributor

Indeed, this could be very useful

@nicolas-grekas
Copy link
Member

before reviewing, do you still want this in core? can you please rebase + fix review comments if yes?

@lyrixx
Copy link
MemberAuthor

Yes it would be very useful!

I'll rebase it ASAP 👍🏼

@fabpotfabpot modified the milestones:5.4,6.1Oct 30, 2021
@fabpotfabpot modified the milestones:6.1,6.2May 20, 2022
@lyrixxlyrixxforce-pushed themessenger-and-class-moved branch 4 times, most recently from6d37c94 to292d6cfCompareAugust 13, 2022 09:05
@lyrixx
Copy link
MemberAuthor

I rebased the PR. and added some tests.

@lyrixxlyrixxforce-pushed themessenger-and-class-moved branch 2 times, most recently from4c0d36f to6e3065aCompareAugust 16, 2022 08:28
@lyrixxlyrixx requested review fromOskarStark and removed request forsrozeAugust 17, 2022 08:23
@lyrixxlyrixxforce-pushed themessenger-and-class-moved branch from6e3065a to8ae4ed5CompareAugust 30, 2022 13:44
Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM after two minor CS changes. Thanks.

@lyrixxlyrixxforce-pushed themessenger-and-class-moved branch from8ae4ed5 to34229afCompareAugust 30, 2022 14:10
@lyrixx
Copy link
MemberAuthor

@nicolas-grekas I addressed your comments, replay all examples, and updated the PR description. I think it's OK

@fabpot
Copy link
Member

Thank you@lyrixx.

@fabpotfabpot merged commite788a49 intosymfony:6.2Sep 1, 2022
@lyrixxlyrixx deleted the messenger-and-class-moved branchSeptember 1, 2022 07:11
xabbuh added a commit that referenced this pull requestSep 2, 2022
This PR was merged into the 6.2 branch.Discussion----------Fix typo in method retrySpecificEnvelopes| Q             | A| ------------- | ---| Branch?       | 6.2| Bug fix?      | yes| New feature?  | no| Deprecations? | no| Tickets       | Fix for#39622| License       | MITCommits-------e5675ac fix typo in method retrySpecificEnvelopes
fabpot added a commit that referenced this pull requestOct 1, 2022
… of passing boolean flags (xabbuh)This PR was merged into the 6.2 branch.Discussion----------[Messenger] add dedicated method for disabling instead of passing boolean flags| Q             | A| ------------- | ---| Branch?       | 6.2| Bug fix?      | no| New feature?  | yes (changes#39622)| Deprecations? | no| Tickets       || License       | MIT| Doc PR        |Commits-------99fac74 add dedicated method for disabling instead of passing boolean flags
@jbdelhommeau
Copy link
Contributor

It will be planned to backport to 6.1 ?
We have this problem with the 5.4 and 6.1 !

@OskarStark
Copy link
Contributor

No, it will be released in 6.2 only

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@OskarStarkOskarStarkAwaiting requested review from OskarStark

+1 more reviewer

@KorbeilKorbeilKorbeil left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

6.2

Development

Successfully merging this pull request may close these issues.

8 participants

@lyrixx@maxhelias@nicolas-grekas@fabpot@jbdelhommeau@OskarStark@Korbeil@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp