@@ -783,6 +783,67 @@ reset the service container between two messages:
783783
784784.. _messenger-retries-failures :
785785
786+ Rate limited transport
787+ ~~~~~~~~~~~~~~~~
788+
789+ Sometimes you might need to rate limit your message worker. You can configure a
790+ rate limiter on transport (requires the :doc: `RateLimiter component </rate-limiter >`)
791+ by setting its ``rate_limiter `` option.
792+
793+ .. configuration-block ::
794+
795+ .. code-block :: yaml
796+
797+ # config/packages/messenger.yaml
798+ framework :
799+ messenger :
800+ transports :
801+ async :
802+ rate_limiter : your_rate_limiter_name
803+
804+ .. code-block :: xml
805+
806+ <!-- config/packages/messenger.xml -->
807+ <?xml version =" 1.0" encoding =" UTF-8" ?>
808+ <container xmlns =" http://symfony.com/schema/dic/services"
809+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
810+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
811+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
812+ https://symfony.com/schema/dic/services/services-1.0.xsd
813+ http://symfony.com/schema/dic/symfony
814+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
815+
816+ <framework : config >
817+ <framework : messenger >
818+ <framework : transport name =" async" >
819+ <option key =" rate_limiter" >your_rate_limiter_name</option >
820+ </framework : transport >
821+ </framework : messenger >
822+ </framework : config >
823+ </container >
824+
825+ .. code-block :: php
826+
827+ // config/packages/messenger.php
828+ use Symfony\Config\FrameworkConfig;
829+
830+ return static function (FrameworkConfig $framework) {
831+ $framework->messenger()
832+ ->transport('async')
833+ ->options(['rate_limiter' => 'your_rate_limiter_name'])
834+ ;
835+ };
836+
837+ .. versionadded :: 6.2
838+
839+ The ``rate_limiter `` option was introduced in Symfony 6.2.
840+
841+ .. caution ::
842+
843+ When a rate limiter is configured on a transport, it will block the whole
844+ worker when the limit is hit. You should make sure you configure a dedicated
845+ worker for a rate limited transport to avoid other transports to be blocked!
846+
786847Retries & Failures
787848------------------
788849
0 commit comments