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