Skip to content

Commit 46cf330

Browse files
[Messenger] Add example of how to use attribute Senders
1 parent 8f8b1e8 commit 46cf330

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

messenger.rst

+18
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,24 @@ to multiple transports:
313313
$messenger->routing('My\Message\ToBeSentToTwoSenders')->senders(['async', 'audit']);
314314
};
315315
316+
.. versionadded:: 5.3
317+
318+
Ability to configure routing using attributes was introduced in Symfony 5.3.
319+
320+
If you are using PHP 8.0 or above, you can use ``Senders`` attribute instead
321+
of ``routing`` key in the configuration:
322+
323+
// src/Message/AsyncMessage.php
324+
namespace App\Message;
325+
326+
use Symfony\Component\Messenger\Attribute\Senders;
327+
328+
#[Senders('async')]
329+
class AsyncMessage
330+
{
331+
// ...
332+
}
333+
316334
.. note::
317335

318336
If you configure routing for both a child and parent class, both rules

0 commit comments

Comments
 (0)