Skip to content

[BUGFIX] Allow to configure RateLimiters in message consumer #1245

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
TYPO3IncTeam opened this issue Apr 22, 2025 · 0 comments
Open

[BUGFIX] Allow to configure RateLimiters in message consumer #1245

TYPO3IncTeam opened this issue Apr 22, 2025 · 0 comments
Labels
13.4.x help wanted Extra attention is needed

Comments

@TYPO3IncTeam
Copy link
Collaborator

ℹ️ View this commit on Github
👥 Authored by Sascha Nowak [email protected]
✔️ Merged by Benni Mack [email protected]

Commit message

[BUGFIX] Allow to configure RateLimiters in message consumer

This fix adds the missing configuration options for the rate limiters.
A "rate limiter" manages the frequency at which a particular messages,
such as an HTTP request or a login attempt, can occur. Rate limiting
serves as a protective mechanism to prevent services from being
overwhelmed by excessive usage, whether intentional or accidental, thus
ensuring their continued availability. Additionally, it proves
beneficial in regulating internal or outbound processes, such as
limiting the simultaneous processing of messages.

Resolves: #103140
Releases: main, 13.4
Change-Id: I248e97fbd2d969986513cfc4f8b3a8ffaab585d4
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83052
Reviewed-by: Garvin Hicking [email protected]
Tested-by: Garvin Hicking [email protected]
Tested-by: core-ci [email protected]
Tested-by: Benni Mack [email protected]
Reviewed-by: Benni Mack [email protected]

➕ Added files

13.4.x/Important-103140-AllowToConfigureRateLimiters.rst
.. include:: /Includes.rst.txt

.. _important-103140-1708522119:

=============================================================================================
Important: #103140 - Allow to configure rate limiters in Message consumer (Symfony Messenger)
=============================================================================================

See :issue:`103140`

Description
===========

This change introduces missing configuration options for Symfony Messenger-based
rate limiters.

A **rate limiter** controls how frequently a specific event (e.g., HTTP request
or login attempt) is allowed to occur. It acts as a safeguard to prevent services from
being overwhelmed — either accidentally or intentionally — thus helping
to maintain their availability.

Rate limiters are also useful for controlling internal or outbound
processes, such as limiting the simultaneous processing of messages.

More information about the rate limiter is available in the
`Symfony Rate Limiter component documentation
<https://symfony.com/doc/current/rate_limiter.html>`__.

Usage
=====

Configure a rate limiter per queue
----------------------------------

Rate limiters can be defined in your service configuration
:file:`EXT:yourext/Configuration/Services.yaml`. The name specified
in the settings is resolved to a service tagged with `messenger.rate_limiter`
and the corresponding identifier.

Example Configuration:

..  code-block:: yaml
    :caption: EXT:yourext/Configuration/Services.yaml
    :emphasize-lines: 10-12,23-25

    messenger.rate_limiter.demo:
      class: 'Symfony\Component\RateLimiter\RateLimiterFactory'
      arguments:
        $config:
          id: 'demo'
          policy: 'sliding_window'
          limit: '100'
          interval: '60 seconds'
        $storage: '@Symfony\Component\RateLimiter\Storage\InMemoryStorage'
      tags:
        - name: 'messenger.rate_limiter'
          identifier: 'demo'

    messenger.rate_limiter.default:
      class: 'Symfony\Component\RateLimiter\RateLimiterFactory'
      arguments:
        $config:
          id: 'default'
          policy: 'sliding_window'
          limit: '100'
          interval: '60 seconds'
        $storage: '@Symfony\Component\RateLimiter\Storage\InMemoryStorage'
      tags:
        - name: 'messenger.rate_limiter'
          identifier: 'default'

.. index:: PHP-API, ext:core
@linawolf linawolf added the help wanted Extra attention is needed label Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
13.4.x help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants