Description
Summary (*)
Magento 2.4.1 shipped with a bunch of new options for message queue consumers based upon an architectural proposition.
But after playing around with it, I'm seeing some inconsistencies and things which don't work like how I originally envisioned this. I'm basing my findings on what I found by playing around, maybe I missed something, maybe not everything is documented properly yet, so there might be mistakes here.
Currently you can configure a bunch of settings in the queue_consumer.xml
file, only some things in the env.php
file and you have very little flexibility to override a particular setting if you aren't happy with the global default or default setting from the queue_consumer.xml
file.
So here is a proposal about how these options can be configured in such a way that they are flexible enough for most cases.
This is about these configuration options btw:
maxMessages
maxIdleTime
sleep
onlySpawnWhenMessageAvailable
consumers_wait_for_messages
Global default | Consumer default | Global override | Consumer override | |
---|---|---|---|---|
Summary | Some global default for these configuration options should always exist | The queue_consumer.xml file in a module should be allowed to override these global defaults |
A devops engineer might want to override the global defaults in the app/etc/env.php file.This override should only apply when the queue_consumer.xml doesn't have a specific value set. |
A devops engineer might want to override the config values of a particular consumer using the app/etc/env.php file. |
Example | maxMessages: 10000 (defined somewhere in code) | See this for example, it overrides it to 5000 | Should be possible to define this in the env.php file: 'queue' => [ 'max_messages' => 10, ], |
Should be possible to define this in the env.php file: 'queue' => [ 'config' => [ 'consumers' => [ 'product_action_attribute.update' => [ 'max_messages' => 5, ], ], ], ], |
Feature exists in Magento (y/n) | This already exists for most/all options I think? | This functionality exists and is being used in some core Magento modules | As far as I can tell, this is currently not possible | As far as I can tell, this is currently not possible |
In the example above, the end result should be that the product_action_attribute.update
consumer runs with a setting of maxMessages
set to 5
Please ignore for a bit that you can override the maxMessages
option in the env.php
file in the cron_consumers_runner
section, I think we should deprecate that somehow or figure out a way to make it backwards compatible with the new proposal from above as it's more flexible.
Here's an example of a bunch of cases with how the outcome should be:
Global default | Consumer default | Global override | Consumer override | Outcome |
---|---|---|---|---|
1000 | - | - | - | 1000 |
1000 | 500 | - | - | 500 |
1000 | - | 300 | - | 300 |
1000 | - | - | 200 | 200 |
1000 | 500 | 300 | - | 500 |
1000 | 500 | - | 200 | 200 |
1000 | 500 | 300 | 200 | 200 |
1000 | - | 300 | 200 | 200 |
I hope this makes sense somehow.
The goal for me would be to be able to very specifically tailor per consumer how it behaves in a certain project on a certain environment (dev/staging/production). Currently we have very little flexibility and have to work with a bunch of defaults Magento set and no easy way to override them.
I'm open for discussion about this, but I'm leaving in a big holiday in a few days. I'll do my best to start answering somewhere from halfway December or January...
Examples (*)
See above
Proposed solution
See above
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users with no workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Activity