Whenever you use more than one storage during the action, no matter if this is HTTP or during handling message asynchronously, one storage may fail. If that will be the case, your state will be correct partially. You may end up with records in database and no message being published to Message Broker or opposite can happen.
For critical parts of the system we want to have assurance that no message will be lost.
To solve this Ecotone implements Outbox pattern like solution. In order to make sure your messages are stored together with your changes we need to set up Dbal Module for database connection you use for storing data. And then set up dbal asynchronous channel for your handlers.
Dbal Message Channel
public function enableRabbitMQ()
Asynchronous Event Handler
public function notifyAboutNewOrder(OrderWasPlaced $event) : void
// notify about new order
After this all your messages will be go through your database as a message channel. All messages will be stored together with your other changes and will be wrapped in same transaction.
In case of need to scale, you may run as many consumers as you want for given dbal channel.