@@ -2222,51 +2222,36 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``::
2222
2222
Customizing Handlers
2223
2223
--------------------
2224
2224
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
-
2259
2225
.. _messenger-handler-config :
2260
2226
2261
2227
Manually Configuring Handlers
2262
2228
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2263
2229
2264
2230
Symfony will normally :ref: `find and register your handler automatically <messenger-handler >`.
2265
2231
But, 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 ``.
2267
2234
2268
2235
.. configuration-block ::
2269
2236
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
+
2270
2255
.. code-block :: yaml
2271
2256
2272
2257
# config/services.yaml
0 commit comments