@@ -904,6 +904,67 @@ running the ``messenger:consume`` command.
904
904
905
905
.. _messenger-retries-failures :
906
906
907
+ Rate limited transport
908
+ ~~~~~~~~~~~~~~~~~~~~~~
909
+
910
+ .. versionadded :: 6.2
911
+
912
+ The ``rate_limiter `` option was introduced in Symfony 6.2.
913
+
914
+ Sometimes you might need to rate limit your message worker. You can configure a
915
+ rate limiter on a transport (requires the :doc: `RateLimiter component </rate-limiter >`)
916
+ by setting its ``rate_limiter `` option:
917
+
918
+ .. configuration-block ::
919
+
920
+ .. code-block :: yaml
921
+
922
+ # config/packages/messenger.yaml
923
+ framework :
924
+ messenger :
925
+ transports :
926
+ async :
927
+ rate_limiter : your_rate_limiter_name
928
+
929
+ .. code-block :: xml
930
+
931
+ <!-- config/packages/messenger.xml -->
932
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
933
+ <container xmlns =" http://symfony.com/schema/dic/services"
934
+ xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
935
+ xmlns : framework =" http://symfony.com/schema/dic/symfony"
936
+ xsi : schemaLocation =" http://symfony.com/schema/dic/services
937
+ https://symfony.com/schema/dic/services/services-1.0.xsd
938
+ http://symfony.com/schema/dic/symfony
939
+ https://symfony.com/schema/dic/symfony/symfony-1.0.xsd" >
940
+
941
+ <framework : config >
942
+ <framework : messenger >
943
+ <framework : transport name =" async" >
944
+ <option key =" rate_limiter" >your_rate_limiter_name</option >
945
+ </framework : transport >
946
+ </framework : messenger >
947
+ </framework : config >
948
+ </container >
949
+
950
+ .. code-block :: php
951
+
952
+ // config/packages/messenger.php
953
+ use Symfony\Config\FrameworkConfig;
954
+
955
+ return static function (FrameworkConfig $framework) {
956
+ $framework->messenger()
957
+ ->transport('async')
958
+ ->options(['rate_limiter' => 'your_rate_limiter_name'])
959
+ ;
960
+ };
961
+
962
+ .. caution ::
963
+
964
+ When a rate limiter is configured on a transport, it will block the whole
965
+ worker when the limit is hit. You should make sure you configure a dedicated
966
+ worker for a rate limited transport to avoid other transports to be blocked.
967
+
907
968
Retries & Failures
908
969
------------------
909
970
0 commit comments