@@ -2171,51 +2171,36 @@ wherever you need a query bus behavior instead of the ``MessageBusInterface``::
2171
2171
Customizing Handlers
2172
2172
--------------------
2173
2173
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
-
2208
2174
.. _messenger-handler-config :
2209
2175
2210
2176
Manually Configuring Handlers
2211
2177
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2212
2178
2213
2179
Symfony will normally :ref: `find and register your handler automatically <messenger-handler >`.
2214
2180
But, 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 ``.
2216
2183
2217
2184
.. configuration-block ::
2218
2185
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
+
2219
2204
.. code-block :: yaml
2220
2205
2221
2206
# config/services.yaml
0 commit comments