From ec2c1552d34507d6e5f8782570f72499f466929b Mon Sep 17 00:00:00 2001 From: Bob van de Vijver Date: Thu, 18 Aug 2022 12:28:18 +0200 Subject: [PATCH] [Messenger] Add messenger rate_limiter docs --- messenger.rst | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/messenger.rst b/messenger.rst index 44bdb0f4c92..c5e15aa84e2 100644 --- a/messenger.rst +++ b/messenger.rst @@ -904,6 +904,67 @@ running the ``messenger:consume`` command. .. _messenger-retries-failures: +Rate limited transport +~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 6.2 + + The ``rate_limiter`` option was introduced in Symfony 6.2. + +Sometimes you might need to rate limit your message worker. You can configure a +rate limiter on a transport (requires the :doc:`RateLimiter component `) +by setting its ``rate_limiter`` option: + +.. configuration-block:: + + .. code-block:: yaml + + # config/packages/messenger.yaml + framework: + messenger: + transports: + async: + rate_limiter: your_rate_limiter_name + + .. code-block:: xml + + + + + + + + + + + + + + + .. code-block:: php + + // config/packages/messenger.php + use Symfony\Config\FrameworkConfig; + + return static function (FrameworkConfig $framework) { + $framework->messenger() + ->transport('async') + ->options(['rate_limiter' => 'your_rate_limiter_name']) + ; + }; + +.. caution:: + + When a rate limiter is configured on a transport, it will block the whole + worker when the limit is hit. You should make sure you configure a dedicated + worker for a rate limited transport to avoid other transports to be blocked. + Retries & Failures ------------------