Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitec2c155

Browse files
bobvandevijverOskarStark
authored andcommitted
[Messenger] Add messenger rate_limiter docs
1 parent69062c2 commitec2c155

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

‎messenger.rst‎

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,67 @@ running the ``messenger:consume`` command.
904904

905905
.. _messenger-retries-failures:
906906

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+
<containerxmlns="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:transportname="async">
944+
<optionkey="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+
907968
Retries & Failures
908969
------------------
909970

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp