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

NEXT-31249 - async low priority queue documentation #1153

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions guides/hosting/infrastructure/message-queue.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nav:
## Overview

::: warning
Parts of this guide refer to the `async_low_priority` queue which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist.
Parts of this guide refer to the `low_priority` queue which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist.
MoritzKrafeld marked this conversation as resolved.
Show resolved Hide resolved
:::

Shopware uses the Symfony Messenger component and Enqueue to handle asynchronous messages. This allows tasks to be processed in the background. Thus, tasks can be processed independently of timeouts or system crashes. By default, tasks in Shopware are stored in the database and processed via the browser as long as you are logged into the Administration. This is a simple and fast method for the development process, but not recommended for production systems. With multiple users logged into the Administration, this can lead to a high CPU load and interfere with the smooth execution of PHP FPM.
Expand Down Expand Up @@ -50,7 +50,7 @@ You can also configure the command to consume messages from multiple transports,
```bash

```bash
bin/console messenger:consume async async_low_priority
bin/console messenger:consume async low_priority
```

For more information about the command and its configuration, use the -h option:
Expand Down Expand Up @@ -89,7 +89,7 @@ User=www-data # Change this to webserver's user name
Restart=always
# Change the path to your shop path
WorkingDirectory=/var/www/html
ExecStart=php /var/www/html/bin/console messenger:consume --time-limit=60 --memory-limit=512M async async_low_priority
ExecStart=php /var/www/html/bin/console messenger:consume --time-limit=60 --memory-limit=512M async low_priority

[Install]
WantedBy=shopware_consumer.target
Expand Down Expand Up @@ -121,7 +121,7 @@ Please refer to the [Symfony documentation](https://symfony.com/doc/current/mess
### Admin worker

::: warning
The `transports` option can only be configured with the `async_low_priority` transport if you are on version 6.5.7.0 or above. You must not add the `async_low_priority` transport in lower versions as the admin worker will fail when it tries to consume a non-existent transport.
The `transports` option can only be configured with the `low_priority` transport if you are on version 6.5.7.0 or above. You must not add the `low_priority` transport in lower versions as the admin worker will fail when it tries to consume a non-existent transport.
MoritzKrafeld marked this conversation as resolved.
Show resolved Hide resolved
:::

The admin worker, if used, can be configured in the general `shopware.yml` configuration. If you want to use the admin worker, you have to specify each transport that was previously configured. The poll interval is the time in seconds that the admin worker polls messages from the queue. After the poll interval is over, the request terminates, and the Administration initiates a new request.
Expand All @@ -132,7 +132,7 @@ shopware:
admin_worker:
enable_admin_worker: true
poll_interval: 30
transports: ["async", "async_low_priority"]
transports: ["async", "low_priority"]
```

## Sending mails over the message queue
Expand All @@ -159,7 +159,7 @@ You can find all available transport options in the Symfony Messenger documentat
Following environment variables are in use out of the box:

* `MESSENGER_TRANSPORT_DSN` - The DSN to the transport to use (e.g. `doctrine://default`).
* `MESSENGER_TRANSPORT_LOW_PRIORITY_DSN` - The DSN to the transport to use for low priority messages (e.g. `doctrine://default?queue_name=async_low_priority`).
* `MESSENGER_TRANSPORT_LOW_PRIORITY_DSN` - The DSN to the transport to use for low priority messages (e.g. `doctrine://default?queue_name=low_priority`).
* `MESSENGER_TRANSPORT_FAILURE_DSN` - The DSN to the transport to use for failed messages (e.g. `doctrine://default?queue_name=failed`).

## Worker count for efficient message processing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nav:
## Overview

::: warning
Parts of this guide refer to the `async_low_priority` queue which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist.
Parts of this guide refer to the `low_priority` queue which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist.
MoritzKrafeld marked this conversation as resolved.
Show resolved Hide resolved
:::

In this guide you'll learn how to create a message handler.
Expand Down Expand Up @@ -57,10 +57,10 @@ You can also append more transports to the command, so the worker will consume m

```bash
//
bin/console messenger:consume async async_low_priority
bin/console messenger:consume async low_priority
```

Where `async` and `async_low_priority` are the transports you want to consume messages from. There is also an API route that lets you consume messages for a given transport. send a `POST` request to the route `/api/_action/message-queue/consume` and define the transport which you want to consume:
Where `async` and `low_priority` are the transports you want to consume messages from. There is also an API route that lets you consume messages for a given transport. send a `POST` request to the route `/api/_action/message-queue/consume` and define the transport which you want to consume:

```js
// on
Expand Down Expand Up @@ -88,12 +88,12 @@ The recommended way to consume messages is through the cli command. You can conf

```bash
//
bin/console messenger:consume async async_low_priority --time-limit=60
bin/console messenger:consume async low_priority --time-limit=60
```

```bash
//
bin/console messenger:consume async async_low_priority --memory-limit=128M
bin/console messenger:consume async low_priority --memory-limit=128M
```

For more information about the command and its configuration use the `-h` option:
Expand Down Expand Up @@ -176,7 +176,7 @@ You can route messages by their classname and use the asterisk as a fallback for
### Admin worker

::: warning
The `transports` option can only be configured with the `async_low_priority` transport if you are on version 6.5.7.0 or above. You must not add the `async_low_priority` transport in lower versions as the admin worker will fail when it tries to consume a non-existent transport.
The `transports` option can only be configured with the `low_priority` transport if you are on version 6.5.7.0 or above. You must not add the `low_priority` transport in lower versions as the admin worker will fail when it tries to consume a non-existent transport.
MoritzKrafeld marked this conversation as resolved.
Show resolved Hide resolved
:::

The admin-worker can be configured or disabled in the general `shopware.yml` configuration. If you want to use the admin worker you have to specify each transport, that previously was configured. The poll interval is the time in seconds that the admin-worker polls messages from the queue. After the poll-interval is over the request terminates and the Administration initiates a new request.
Expand All @@ -187,7 +187,7 @@ shopware:
admin_worker:
enable_admin_worker: true
poll_interval: 30
transports: ["async", "async_low_priority"]
transports: ["async", "low_priority"]
```

## Next steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ nav:
## Overview

::: warning
Parts of this guide refer to the `async_low_priority` queue and the corresponding `AsyncLowPriorityMessageInterface` which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist.
Parts of this guide refer to the `low_priority` queue and the corresponding `AsyncLowPriorityMessageInterface` which is only available in version 6.5.7.0 and above. Configuring the messenger to consume this queue will fail, if it does not exist.
MoritzKrafeld marked this conversation as resolved.
Show resolved Hide resolved
:::

In this guide you'll learn how to create a message and add it to the queue.
Expand Down