@@ -881,6 +881,67 @@ running the ``messenger:consume`` command.
881881
882882.. _messenger-retries-failures :
883883
884+ Rate limited transport
885+ ~~~~~~~~~~~~~~~~~~~~~~
886+
887+ .. versionadded :: 6.2
888+
889+ The ``rate_limiter `` option was introduced in Symfony 6.2.
890+
891+ Sometimes you might need to rate limit your message worker. You can configure a
892+ rate limiter on a transport (requires the :doc: `RateLimiter component </rate-limiter >`)
893+ by setting its ``rate_limiter `` option:
894+
895+ .. configuration-block ::
896+
897+ .. code-block :: yaml
898+
899+ # config/packages/messenger.yaml
900+ framework :
901+ messenger :
902+ transports :
903+ async :
904+ rate_limiter : your_rate_limiter_name
905+
906+ .. code-block :: xml
907+
908+ <!-- config/packages/messenger.xml -->
909+ <?xml version =" 1.0" encoding =" UTF-8" ?>
910+ <container xmlns =" http://symfony.com/schema/dic/services"
911+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
912+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
913+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
914+ https://symfony.com/schema/dic/services/services-1.0.xsd
915+ http://symfony.com/schema/dic/symfony
916+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
917+
918+ <framework : config >
919+ <framework : messenger >
920+ <framework : transport name =" async" >
921+ <option key =" rate_limiter" >your_rate_limiter_name</option >
922+ </framework : transport >
923+ </framework : messenger >
924+ </framework : config >
925+ </container >
926+
927+ .. code-block :: php
928+
929+ // config/packages/messenger.php
930+ use Symfony\Config\FrameworkConfig;
931+
932+ return static function (FrameworkConfig $framework) {
933+ $framework->messenger()
934+ ->transport('async')
935+ ->options(['rate_limiter' => 'your_rate_limiter_name'])
936+ ;
937+ };
938+
939+ .. caution ::
940+
941+ When a rate limiter is configured on a transport, it will block the whole
942+ worker when the limit is hit. You should make sure you configure a dedicated
943+ worker for a rate limited transport to avoid other transports to be blocked.
944+
884945Retries & Failures
885946------------------
886947
0 commit comments