Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit 8ff3e6e

Browse files
committed
create topic for queue subcommands
1 parent 6edb9c2 commit 8ff3e6e

File tree

4 files changed

+134
-1
lines changed

4 files changed

+134
-1
lines changed

_data/toc/configuration-guide.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ pages:
103103
- label: Set the Magento mode
104104
url: /config-guide/cli/config-cli-subcommands-mode.html
105105

106+
- label: Start message queue consumers
107+
include_versions: ["2.3"]
108+
url: /config-guide/cli/config-cli-subcommands-queue.html
109+
106110
- label: URN highlighter
107111
url: /config-guide/cli/config-cli-subcommands-urn.html
108112

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
## View a list of available message queue consumers
2+
3+
To view a list of all consumers:
4+
5+
```bash
6+
bin/magento queue:consumers:list
7+
```
8+
9+
The list displays as follows:
10+
11+
```
12+
sharedCatalogUpdatePrice
13+
sharedCatalogUpdateCategoryPermissions
14+
quoteItemCleaner
15+
inventoryQtyCounter
16+
async.operations.all
17+
```
18+
19+
## Start message queue consumers
20+
21+
To start message queue consumers:
22+
23+
```bash
24+
/bin/magento queue:consumers:start [--max-messages=<value>] [--batch-size=<value>] [--pid-file-path=<value>] <consumer_name>
25+
```
26+
27+
The following table explains this command’s options, parameters, and values.
28+
29+
Parameter | Value | Required?
30+
--- | --- | ---
31+
`--max-messages=<value>` | The maximum number of messages to consume per invocation. If the number of queued messages is less than the specified max, the consumer polls for new messages until it has processed the max. If you don't specify `--max-messages`, the process runs continuously. | No
32+
`--batch-size=<value>` | The number of messages to consume per batch. If specified, messages in a queue are consumed in batches of `<value>` each. This option is applicable for the batch consumer only. If `--batch-size` is not defined, the batch consumer receives all available messages in a queue. | No
33+
`--pid-file-path=<value>` | The file path for saving PID of consumer process. | No
34+
`<consumer_name>` | The consumer to start. | Yes
35+
{:style="table-layout:auto;"}
36+
37+
After consuming all available messages, the command terminates. You can run the command again manually or with a cron job. You can also run multiple instances of the `magento queue:consumers:start` command to process large message queues. For example, you can append `&` to the command to run it in the background, return to a prompt, and continue running commands:
38+
39+
```bash
40+
bin/magento queue:consumers:start <consumer_name> &
41+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
group: configuration-guide
3+
title: Start message queue consumers
4+
functional_areas:
5+
- Configuration
6+
- System
7+
- Setup
8+
---
9+
10+
{% include config/cli-intro.md %}
11+
12+
You must start a message queue consumer to enable asynchronous operations such as Inventory Management mass actions and REST bulk and asynchronous endpoints. To enable B2B functionality, you must start multiple consumers. Third-party modules might also require that you start a custom consumer.
13+
14+
{% include config/message-queue-consumers.md %}
15+
16+
## Related topics
17+
18+
* [Message queues overview]({{ page.baseurl }}/config-guide/mq/rabbitmq-overview.html)
19+
* [Manage message queues]({{ page.baseurl }}/config-guide/mq/manage-mysql.html)

guides/v2.3/config-guide/mq/manage-mysql.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
---
2+
group: configuration-guide
3+
title: Manage message queues
4+
functional_areas:
5+
- Configuration
6+
- System
7+
- Setup
8+
---
9+
10+
11+
If you don't want to implement the RabbitMQ solution, you can manage message queues with cron jobs (or an external process manager) and the command line to ensure that consumers are retrieving messages.
12+
13+
## Process management
14+
15+
Cron jobs are the default mechanism to restart consumers. Processes started by `cron` consume the specified number of messages and then terminate. Re-running `cron` restarts the consumer.
16+
17+
The following shows a `crontab` configuration for running consumers in our implementation, it is the example for understanding how it works:
18+
19+
*/app/code/Magento/MessageQueue/etc/crontab.xml*
20+
21+
```xml
22+
...
23+
<job name="consumers_runner" instance="Magento\MessageQueue\Model\Cron\ConsumersRunner" method="run">
24+
<schedule>* * * * *</schedule>
25+
</job>
26+
...
27+
```
28+
29+
{:.bs-callout .bs-callout-info}
30+
How often you check message queues depends on your business logic and available system resources. In general, you'll probably want to check for newly created customers and send welcome emails more frequently than a more resource intensive process (e.g., updating your catalog). You should define `cron` schedules according to your business needs.<br><br>It can be configured in Admin Panel **Stores > Configuration > Advanced > System > Cron configuration options for group: consumers**<br><br>See [Configure and run cron]({{ page.baseurl }}/config-guide/cli/config-cli-subcommands-cron.html) for more information about using `cron` with Magento.
31+
32+
You can also use a process manager such as [Supervisor](http://supervisord.org/index.html) to monitor the status of processes. The manager can use the command line to restart the processes as needed.
33+
34+
### Configuration
35+
36+
#### Behavior by default
37+
38+
* Cron job `consumers_runner` is enabled
39+
* Cron job `consumers_runner` runs all defined consumers
40+
* Each consumer process 10000 messages and then terminate
41+
42+
#### Specific configuration
43+
44+
Edit */app/etc/env.php* file for configure cron job `consumers_runner`
45+
46+
{% highlight php %}
47+
...
48+
'cron_consumers_runner' => array(
49+
'cron_run' => false,
50+
'max_messages' => 20000,
51+
'consumers' => array(
52+
'consumer1',
53+
'consumer2',
54+
)
55+
),
56+
...
57+
{% endhighlight %}
58+
59+
* `cron_run` - the option for enabling/disabling cron job `consumers_runner`, by default is true.
60+
* `max_messages` - the maximum number of messages for each consumer that must be processed before consumer terminate, by default is 1000. If it is 0, then the consumer never stops working.
61+
* `consumers` - the list of consumers which will be run, by default is empty array (all consumers are allowed to be run).
62+
63+
{% include config/message-queue-consumers.md %}
64+
65+
#### Related Topics
66+
67+
* [Message Queues Overview]({{ page.baseurl }}/config-guide/mq/rabbitmq-overview.html)
68+
* [Configure and run cron]({{ page.baseurl }}/config-guide/cli/config-cli-subcommands-cron.html)
69+
* [Command-line configuration]({{ page.baseurl }}/config-guide/cli/config-cli-subcommands.html)
70+
* [Message Queues]({{ page.baseurl }}/extension-dev-guide/message-queues/message-queues.html)

0 commit comments

Comments
 (0)