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