Skip to content
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

[Messenger][RateLimiter] fix additional message handled when using a rate limiter #58763

Merged
merged 1 commit into from
Nov 9, 2024

Conversation

Jean-Beru
Copy link
Contributor

@Jean-Beru Jean-Beru commented Nov 5, 2024

Q A
Branch? 6.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #57230
License MIT

Fix additional message handled by Messenger when using a rate limiter. A token was reserved but not consumed. See #57230

With the following configuration:

framework:
  rate_limiter:
    test:
      policy: 'fixed_window'
      limit: 1
      interval: '10 seconds'

  messenger:
    transports:
      test:
        dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
        rate_limiter: 'test'
    routing:
      'App\Messenger\DoSomething': 'test'

Log generated by the MessageHandler:

$ bin/console messenger:consume test

                                                                                                                        
 [OK] Consuming messages from transport "test".                                                                         
                                                                                                                        

 // The worker will automatically exit once it has received a stop signal via the messenger:stop-workers command.       

 // Quit the worker with CONTROL-C.                                                                                     

 // Re-run the command with a -vv option to see logs about consumed messages.                                           

09:13:48 WARNING   [app] Message handled
09:13:58 WARNING   [app] Message handled
09:13:58 WARNING   [app] Message handled # Duplicated
09:14:08 WARNING   [app] Message handled
09:14:08 WARNING   [app] Message handled # Duplicated
09:14:18 WARNING   [app] Message handled
09:14:18 WARNING   [app] Message handled # Duplicated

After fix:

bin/console messenger:consume test

                                                                                                                        
 [OK] Consuming messages from transport "test".                                                                         
                                                                                                                        

 // The worker will automatically exit once it has received a stop signal via the messenger:stop-workers command.       

 // Quit the worker with CONTROL-C.                                                                                     

 // Re-run the command with a -vv option to see logs about consumed messages.                                           

09:18:54 WARNING   [app] Message handled
09:19:04 WARNING   [app] Message handled
09:19:14 WARNING   [app] Message handled
09:19:24 WARNING   [app] Message handled

@Jean-Beru Jean-Beru force-pushed the 57230-messenger-rate-limiter branch from 0ccdc52 to ec1b999 Compare November 5, 2024 09:29
@fabpot
Copy link
Member

fabpot commented Nov 9, 2024

Thank you @Jean-Beru.

@fabpot fabpot merged commit 91acfa8 into symfony:6.4 Nov 9, 2024
10 checks passed
This was referenced Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants