@@ -2222,51 +2222,36 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``::
22222222Customizing Handlers
22232223--------------------
22242224
2225- Configuring Handlers Using Attributes
2226- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2227-
2228- You can configure your handler by passing options to the attribute::
2229-
2230- // src/MessageHandler/SmsNotificationHandler.php
2231- namespace App\MessageHandler;
2232-
2233- use App\Message\OtherSmsNotification;
2234- use App\Message\SmsNotification;
2235- use Symfony\Component\Messenger\Attribute\AsMessageHandler;
2236-
2237- #[AsMessageHandler(fromTransport: 'async', priority: 10)]
2238- class SmsNotificationHandler
2239- {
2240- public function __invoke(SmsNotification $message): void
2241- {
2242- // ...
2243- }
2244- }
2245-
2246- Possible options to configure with the attribute are:
2247-
2248- ============================== ====================================================================================================
2249- Option Description
2250- ============================== ====================================================================================================
2251- ``bus `` Name of the bus from which the handler can receive messages, by default all buses.
2252- ``fromTransport `` Name of the transport from which the handler can receive messages, by default all transports.
2253- ``handles `` Type of messages (FQCN) that can be processed by the handler, only needed if can't be guessed by
2254- type-hint.
2255- ``method `` Name of the method that will process the message, only if the target is a class.
2256- ``priority `` Priority of the handler when multiple handlers can process the same message.
2257- ============================== ====================================================================================================
2258-
22592225.. _messenger-handler-config :
22602226
22612227Manually Configuring Handlers
22622228~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
22632229
22642230Symfony will normally :ref: `find and register your handler automatically <messenger-handler >`.
22652231But, you can also configure a handler manually - and pass it some extra config -
2266- by tagging the handler service with ``messenger.message_handler ``
2232+ while using ``#AsMessageHandler `` attribute or tagging the handler service
2233+ with ``messenger.message_handler ``.
22672234
22682235.. configuration-block ::
22692236
2237+ .. code-block :: php-attributes
2238+
2239+ // src/MessageHandler/SmsNotificationHandler.php
2240+ namespace App\MessageHandler;
2241+
2242+ use App\Message\OtherSmsNotification;
2243+ use App\Message\SmsNotification;
2244+ use Symfony\Component\Messenger\Attribute\AsMessageHandler;
2245+
2246+ #[AsMessageHandler(fromTransport: 'async', priority: 10)]
2247+ class SmsNotificationHandler
2248+ {
2249+ public function __invoke(SmsNotification $message): void
2250+ {
2251+ // ...
2252+ }
2253+ }
2254+
22702255 .. code-block :: yaml
22712256
22722257 # config/services.yaml
0 commit comments