Skip to content

Explain HandleMessageInNewTransaction middleware #4

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

Merged
merged 1 commit into from
Feb 24, 2019
Merged

Explain HandleMessageInNewTransaction middleware #4

merged 1 commit into from
Feb 24, 2019

Conversation

gubler
Copy link

@gubler gubler commented Feb 24, 2019

The current PR is for HandleMessageInNewTransaction middleware instead of the original RecordsMessages middleware. This documentation covers the new middleware.

The current PR is for HandleMessageInNewTransaction middleware instead of the original RecordsMessages middleware. This documentation covers the new middleware.
Copy link
Owner

@Nyholm Nyholm left a comment

Choose a reason for hiding this comment

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

Thank you

**Solution:** The solution is to not dispatch the ``UserCreated`` event in the
``CreateUserHandler`` but to just "record" the events. The recorded events will
be dispatched after ``DoctrineTransactionMiddleware`` has committed the transaction.
**Problem 2:** If an exception is thrown when saving the user to the database, the welcome
Copy link
Owner

Choose a reason for hiding this comment

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

Oh, I've never thought about this. That is true. Thanks

@Nyholm Nyholm merged commit ed06dc0 into Nyholm:message-recorder Feb 24, 2019
@Nyholm
Copy link
Owner

Nyholm commented Feb 24, 2019

Your changes has been merged and are now visible on symfony#10015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants