@@ -743,6 +743,67 @@ running the ``messenger:consume`` command.
743
743
744
744
.. _messenger-retries-failures :
745
745
746
+ Rate limited transport
747
+ ~~~~~~~~~~~~~~~~
748
+
749
+ Sometimes you might need to rate limit your message worker. You can configure a
750
+ rate limiter on transport (requires the :doc: `RateLimiter component </rate-limiter >`)
751
+ by setting its ``rate_limiter `` option.
752
+
753
+ .. configuration-block ::
754
+
755
+ .. code-block :: yaml
756
+
757
+ # config/packages/messenger.yaml
758
+ framework :
759
+ messenger :
760
+ transports :
761
+ async :
762
+ rate_limiter : your_rate_limiter_name
763
+
764
+ .. code-block :: xml
765
+
766
+ <!-- config/packages/messenger.xml -->
767
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
768
+ <container xmlns =" http://symfony.com/schema/dic/services"
769
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
770
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
771
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
772
+ https://symfony.com/schema/dic/services/services-1.0.xsd
773
+ http://symfony.com/schema/dic/symfony
774
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
775
+
776
+ <framework : config >
777
+ <framework : messenger >
778
+ <framework : transport name =" async" >
779
+ <option key =" rate_limiter" >your_rate_limiter_name</option >
780
+ </framework : transport >
781
+ </framework : messenger >
782
+ </framework : config >
783
+ </container >
784
+
785
+ .. code-block :: php
786
+
787
+ // config/packages/messenger.php
788
+ use Symfony\Config\FrameworkConfig;
789
+
790
+ return static function (FrameworkConfig $framework) {
791
+ $framework->messenger()
792
+ ->transport('async')
793
+ ->options(['rate_limiter' => 'your_rate_limiter_name'])
794
+ ;
795
+ };
796
+
797
+ .. versionadded :: 6.2
798
+
799
+ The ``rate_limiter `` option was introduced in Symfony 6.2.
800
+
801
+ .. caution ::
802
+
803
+ When a rate limiter is configured on a transport, it will block the whole
804
+ worker when the limit is hit. You should make sure you configure a dedicated
805
+ worker for a rate limited transport to avoid other transports to be blocked!
806
+
746
807
Retries & Failures
747
808
------------------
748
809
0 commit comments