Symfony Messenger Transport
Symfony Messenger CQRS DDD
Last updated
Was this helpful?
Symfony Messenger CQRS DDD
Last updated
Was this helpful?
Ecotone comes with Symfony Messenger Transport integration.
We may use as our .
This way we can work with familiar environment and reuse already set up Symfony Serializer
.
Suppose we have "async" transport:
Then we can register it using in Ecotone:
After that we can start using it as any other .
In order to trigger Command
Event
or Query
Handler, we will be sending the Message
via given Ecotone's Bus, sending Messages via Symfony Bus will have no effect due to lack of information what kind of message it's.
In order to trigger given Bus, inject CommandBus, EventBus or QueryBus (they are automatically available after installing Ecotone) and make use of them to send a Message.
We will be running Message Consumer using "ecotone:run" command:
When sending command and events via routing, it's possible to use non-class types. In case of Symfony however, Messenger Transports require to Classes. To solve that Ecotone wraps simple types in a class and unwrap it on deserialization. Thanks to that we can Symfony Transport like any other Ecotone's Message Channel.
Command Handler with command having array payload
In case of sending events, we will be using Event Bus.
EventBus is available out of the box in Dependency Container. Therefore all we need to do, is to inject it and publish an Event
Subscribe to Event
Command Handler inside with command having no payload
at all
Failed transport is configured on Ecotone side using Error Channel. Read more in .