Description
Symfony version(s) affected
6.4.x
Description
I was testing a rate limited mailer messenger transport configuration and noticed that more messages were consumed by the messenger than the rate limit actually allows - at least with a certain configuration.
How to reproduce
Create a configuration that looks like this for example:
framework:
mailer:
dsn: '%env(MAILER_DSN)%'
rate_limiter:
mailer:
policy: fixed_window
limit: 1
interval: 1 minute
messenger:
transports:
mailer:
dsn: 'doctrine://default?queue_name=mailer'
rate_limiter: mailer
routing:
'Symfony\Component\Mailer\Messenger\SendEmailMessage': mailer
i.e. only allow 1 email per minute. Then execute messenger:setup-transports
.
Then create a bunch of emails in your system. Unfortunately you cannot use the mailer:test
command for that as it directly sends the email rather than using the Mailer
service to send it via the messenger bus - so you'll have to create your own command/service/code that sends a bunch of email messages via the Mailer
.
Now execute messenger:consume mailer
to keep consuming messages for the mailer
messenger transport. You will notice that at first only one email is sent. However, after every 60 seconds two emails are sent after that, instead of the expected one email per minute.
Possible Solution
No response
Additional Context
No response