@@ -2171,51 +2171,36 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``::
21712171Customizing Handlers
21722172--------------------
21732173
2174- Configuring Handlers Using Attributes
2175- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2176-
2177- You can configure your handler by passing options to the attribute::
2178-
2179- // src/MessageHandler/SmsNotificationHandler.php
2180- namespace App\MessageHandler;
2181-
2182- use App\Message\OtherSmsNotification;
2183- use App\Message\SmsNotification;
2184- use Symfony\Component\Messenger\Attribute\AsMessageHandler;
2185-
2186- #[AsMessageHandler(fromTransport: 'async', priority: 10)]
2187- class SmsNotificationHandler
2188- {
2189- public function __invoke(SmsNotification $message): void
2190- {
2191- // ...
2192- }
2193- }
2194-
2195- Possible options to configure with the attribute are:
2196-
2197- ============================== ====================================================================================================
2198- Option Description
2199- ============================== ====================================================================================================
2200- ``bus `` Name of the bus from which the handler can receive messages, by default all buses.
2201- ``fromTransport `` Name of the transport from which the handler can receive messages, by default all transports.
2202- ``handles `` Type of messages (FQCN) that can be processed by the handler, only needed if can't be guessed by
2203- type-hint.
2204- ``method `` Name of the method that will process the message, only if the target is a class.
2205- ``priority `` Priority of the handler when multiple handlers can process the same message.
2206- ============================== ====================================================================================================
2207-
22082174.. _messenger-handler-config :
22092175
22102176Manually Configuring Handlers
22112177~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22122178
22132179Symfony will normally :ref: `find and register your handler automatically <messenger-handler >`.
22142180But, you can also configure a handler manually - and pass it some extra config -
2215- by tagging the handler service with ``messenger.message_handler ``
2181+ while using ``#AsMessageHandler `` attribute or tagging the handler service
2182+ with ``messenger.message_handler ``.
22162183
22172184.. configuration-block ::
22182185
2186+ .. code-block :: php-attributes
2187+
2188+ // src/MessageHandler/SmsNotificationHandler.php
2189+ namespace App\MessageHandler;
2190+
2191+ use App\Message\OtherSmsNotification;
2192+ use App\Message\SmsNotification;
2193+ use Symfony\Component\Messenger\Attribute\AsMessageHandler;
2194+
2195+ #[AsMessageHandler(fromTransport: 'async', priority: 10)]
2196+ class SmsNotificationHandler
2197+ {
2198+ public function __invoke(SmsNotification $message): void
2199+ {
2200+ // ...
2201+ }
2202+ }
2203+
22192204 .. code-block :: yaml
22202205
22212206 # config/services.yaml
0 commit comments