Shopware Message Queue

Information from shopware

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 high CPU load and interfere with the smooth execution of PHP FPM.

What are systemd user services?

Please see this kb for a more in depth explanations: https://portal.hosted-power.com/knowledgebase/article/139/systemd-user-services-examples/

Systemd user services example Shopware:

Create a file:

 ~/.config/systemd/user/shopware_consumer@.service

[Unit]
Description=Shopware Message Queue Consumer (#%i)
After=network-online.target
Requires=dbus.socket
StartLimitIntervalSec=0 [Service] Type=simple WorkingDirectory=%h/shopware ExecStart=/usr/bin/php8.1 %h/shopware/bin/console messenger:consume --time-limit=3600 --memory-limit=2G --limit=25 RestartSec=10s Restart=always [Install] WantedBy=default.target

Now enable and start 2 instances for example:

systemctl --user enable shopware_consumer@{1..2}
systemctl --user start shopware_consumer@{1..2}

Restart it:

systemctl --user restart shopware_consumer@*.service

Status:

systemctl --user status shopware_consumer@*.service

Disable the admin worker

If you have configured the cli-worker, you should turn off the admin worker in the shopware configuration file, therefore create or edit the configuration shopware.yaml.

# config/packages/shopware.yaml
shopware:
    admin_worker:
        enable_admin_worker: false


Was this article helpful?

mood_bad Dislike 3
mood Like 2
visibility Views: 2044