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] Show how to configure a doctrine transaction middleware#10013

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

Closed
Nyholm wants to merge3 commits intosymfony:masterfromNyholm:doctrine-transaction

Conversation

@Nyholm
Copy link
Member

@NyholmNyholm commentedJul 4, 2018
edited
Loading

This willfix#9651

This is a first draft. Please add a quick review and after that I'll add code blocks for PHP and XML.

I use the title "Working with doctrine" because I believe we should mention the DispatchAfterCurrentBusMiddleware on this page as well. (Code PR,Doc PR) and the "recording" from entities (Code PR)

@javiereguiluzjaviereguiluz changed the title[Messenger] Show ow to configure a doctrine transaction middleware[Messenger] Show how to configure a doctrine transaction middlewareJul 4, 2018
@ogizanagi
Copy link
Contributor

It looks great!...but we already mentioned the transaction middleware briefly inhttps://symfony.com/doc/current/messenger.html#using-middleware-factories where we explain middleware factories.
But having this dedicated docs really makes sense. However end-users should not have to deal with the factories themselves for this middleware as everything should be wired by the DoctrineBundle. So it could be actually simplified butdoctrine/DoctrineBundle#817 isn't merged yet :'(

Users are supposed to be able to just use:

framework:messenger:buses:command_bus:middleware:# Using default entity manager                            -doctrine_transaction_middleware# Using "custom" entity manager                            -doctrine_transaction_middleware:['custom']

@Nyholm
Copy link
MemberAuthor

Oh, I've missed that entire page of documentation!

Okey, Lets wait fordoctrine/DoctrineBundle#817

@Nyholm
Copy link
MemberAuthor

Now when the doctrine PR is merge, I will update these docs to the new config syntax, right?

@NyholmNyholmforce-pushed thedoctrine-transaction branch from43169a3 tocc05ed2CompareApril 8, 2019 19:05
@Nyholm
Copy link
MemberAuthor

This PR is updated.
Ping@sroze

Copy link
Contributor

@srozesroze left a comment

Choose a reason for hiding this comment

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

Looks good to me (except these two changes) 👍

@Nyholm
Copy link
MemberAuthor

Thank you for the review. I've updated the RP

Copy link
Member

@weaverryanweaverryan left a comment

Choose a reason for hiding this comment

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

My instinct is that this should be included in the main doc, but we can figure that out later. I added one real question.

Also, correct me if I'm wrong, isn't this only relevant if you have multiple handlers that are doing flushes? So the transaction would roll back all of them (instead of some working and others not working)? I want it to be clear when a user should definitely use this versus when it won't make any difference for them.

buses:
messenger.bus.command:
middleware:
- validation
Copy link
Member

Choose a reason for hiding this comment

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

are we purposely also including validation?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a bit unrelated with the content of this doc indeed, but a good practice, as content of the command in a CQRS application are most of the input by users (on contrary of events which are mostly crafted by developers from already validated data).

@ogizanagi
Copy link
Contributor

@weaverryan

Also, correct me if I'm wrong, isn't this only relevant if you have multiple handlers that are doing flushes?

No it's relevant even with a single command bus and single handler for the message, so you don't have to deal with flushing changes yourself, nor you can commit changes partially to the database if a command handler failed at some point, rollbacking any change.

@OskarStark
Copy link
Contributor

Friendly ping@Nyholm 🎶 👋

Could you please find some time and finish this PR? Thank you 🙏

@javiereguiluz
Copy link
Member

I'm closing this old pull request because we already mention thedoctrine_transaction in the main Messenger article (seehttps://symfony.com/doc/current/messenger.html#middleware-for-doctrine) so this is probably no longer needed. Thanks.

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

Reviewers

@weaverryanweaverryanweaverryan left review comments

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

+3 more reviewers

@ogizanagiogizanagiogizanagi left review comments

@srozesrozesroze approved these changes

@maxheliasmaxheliasmaxhelias approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Messenger] Add a middleware that wraps all handlers in one Doctrine transaction

9 participants

@Nyholm@ogizanagi@OskarStark@javiereguiluz@weaverryan@nicolas-grekas@sroze@maxhelias@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp