You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we use CommandBusBundle to implement the "event" pattern
in these commands we can record Events that will be handled after the Command has run. all of these events are handled synchronously.
the Domain/Middleware/EventStoreMiddleware.php is registering all events in the DB as OrderEvent and TaskEvent , so we must reimplement it
How to migrate?
In symfony messenger everything is messages ( As far as Messenger is concerned, commands and events all look identical. The difference comes down to each supporting a different design pattern.ref )
So we have just to replace simplebus commands and simplebus events by symfony messenger messages.
We can now use the attribute AsMessageHandler to register the handler automatically !! if we want to have the same behaviour as before, that the events are handled after the command is succesfull, we must use DispatchAfterCurrentBusMiddleware Middleware
Buses
for now we have only one bus, the default bus. we could add a new bus command_bus to replace SimpleBus command, so it would be clearer (and set event_bus as default bus). See doc here
maybe we could even have order_bus and task_bus so it corresponds to what we had before
The middleware are executed when the message is dispatched but also again when a message is received via the worker (for messages that were sent to a transport to be handled asynchronously). Keep this in mind if you create your own middleware.
The text was updated successfully, but these errors were encountered:
SimpleBus support was dropped ~2 years ago in favor of SymfonyMessenger
See: SimpleBus/SimpleBus#37
How is it working now?
Domain/Middleware/EventStoreMiddleware.php
is registering all events in the DB as OrderEvent and TaskEvent , so we must reimplement itHow to migrate?
In symfony messenger everything is messages (
As far as Messenger is concerned, commands and events all look identical. The difference comes down to each supporting a different design pattern.
ref )So we have just to replace simplebus commands and simplebus events by symfony messenger messages.
We can now use the attribute
AsMessageHandler
to register the handler automatically!! if we want to have the same behaviour as before, that the events are handled after the command is succesfull, we must use DispatchAfterCurrentBusMiddleware Middleware
Buses
for now we have only one bus, the default bus. we could add a new bus
command_bus
to replace SimpleBus command, so it would be clearer (and setevent_bus
as default bus). See doc heremaybe we could even have
order_bus
andtask_bus
so it corresponds to what we had beforeRegistering TaskEvent and OrderEvent
We need to register a custom middleware in order to register these entities : https://symfony.com/doc/5.x/messenger.html#middleware
The middleware are executed when the message is dispatched but also again when a message is received via the worker (for messages that were sent to a transport to be handled asynchronously). Keep this in mind if you create your own middleware.
The text was updated successfully, but these errors were encountered: