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

Appearance settings

Commit fff8659

Browse filesBrowse files
Nyholmweaverryan
authored andcommitted
According to feedback
1 parent afdddbf commit fff8659
Copy full SHA for fff8659

File tree

1 file changed

+9
-4
lines changed
Filter options

1 file changed

+9
-4
lines changed

‎messenger/message-recorder.rst

Copy file name to clipboardExpand all lines: messenger/message-recorder.rst
+9-4Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
Record Events Produced by a Handler
55
===================================
66

7-
In a example application there is a command (a CQRS message) named ``CreateUser``.
8-
That command is handled by the ``CreateUserHandler``. The command handler creates
7+
In an example application there is a command (a CQRS message) named ``CreateUser``.
8+
That command is handled by the ``CreateUserHandler`` which creates
99
a ``User`` object, stores that object to a database and dispatches an ``UserCreatedEvent``.
1010
That event is also a normal message but is handled by an *event* bus.
1111

1212
There are many subscribers to the ``UserCreatedEvent``, one subscriber may send
1313
a welcome email to the new user. Since we are using the ``DoctrineTransactionMiddleware``
1414
we wrap all database queries in one database transaction and rollback that transaction
15-
if an exception is thrown. That would mean that if an exception is thrown when sending
15+
if an exception is thrown. That means that if an exception is thrown when sending
1616
the welcome email, then the user will not be created.
1717

1818
The solution to this issue is to not dispatch the ``UserCreatedEvent`` in the
@@ -27,7 +27,7 @@ in the middleware chain.
2727

2828
.. code-block:: yaml
2929
30-
# config/packages/workflow.yaml
30+
# config/packages/messenger.yaml
3131
framework:
3232
messenger:
3333
default_bus: messenger.bus.command
@@ -45,6 +45,11 @@ in the middleware chain.
4545
4646
.. code-block:: php
4747
48+
namespace App\Messenger\CommandHandler;
49+
50+
use App\Entity\User;
51+
use App\Messenger\Command\CreateUser;
52+
use App\Messenger\Event\UserCreatedEvent;
4853
use Doctrine\ORM\EntityManagerInterface;
4954
use Symfony\Component\Messenger\MessageRecorderInterface;
5055

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.