# Symfony Messenger Integration: CQRS and Async Message Processing API Platform provides an integration with the [Symfony Messenger Component](https://symfony.com/doc/current/messenger.html). This feature allows to implement the [Command Query Responsibility Segregation (CQRS)](https://martinfowler.com/bliki/CQRS.html) pattern in a convenient way. It also makes it easy to send messages through the web API that will be consumed asynchronously. Many transports are supported to dispatch messages to async consumers, including RabbitMQ, Apache Kafka, Amazon SQS and Google Pub/Sub. ## Installing Symfony Messenger To enable the support of Messenger, install the library: $ docker-compose exec php composer require messenger ## Dispatching a Resource through the Message Bus Set the `messenger` attribute to `true`, and API Platform will automatically dispatch the API Resource instance as a message using the message bus provided by the Messenger Component: ```php Because the `messenger` attribute is `true`, when a `POST` is handled by API Platform, the corresponding instance of the `ResetPasswordRequest` will be dispatched. For this example, only the `POST` operation is enabled. We use the `status` attribute to configure API Platform to return a [202 Accepted HTTP status code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/202). It indicates that the request has been received and will be treated later, without giving an immediate return to the client. Finally, the `output` attribute is set to `false`, so the HTTP response that will be generated by API Platform will be empty, and the [serialization process](serialization.md) will be skipped. **Note:** using `messenger=true` or `messenger="input"` triggers a dedicated Messenger data persister. Therefore, any other built-in data persisters won't be called (e.g. Doctrine data persister). If you want to send a message after saving an object (like a Doctrine entity), prefer [creating a custom data persister](https://api-platform.com/docs/core/data-persisters/#creating-a-custom-data-persister) to save your object and [dispatch your own message manually](https://symfony.com/doc/current/components/messenger.html#bus). ## Registering a Message Handler To process the message that will be dispatched, [a handler](https://symfony.com/doc/current/messenger.html#registering-handlers) must be created: ```php