You are currently viewing the article on an older Shopware version!

Message Queue

In Shopware 6, many tasks process asynchronously, which means that the tasks are processed in messages in a queue and not at the time of execution. This process allows tasks to be processed independently of timeouts or system crashes. Possible tasks are sending mails, indexing products, or generating the sitemap.

Scheduled Tasks

Recurring tasks are handled via Scheduled Tasks. Scheduled tasks add tasks to the message queue at fixed intervals, which are then also processed asynchronously. For example, this includes generating an export for comparison portals or checking whether new updates are available.

Admin Worker

In a standard installation of Shopware, message queue tasks are stored in the database and processed via the browser, provided you are logged into the Administration. This is a fast and straightforward method but is not recommended for production systems. 

The functioning of the Admin Worker requires that the Administration is open for a more extended time; otherwise, tasks will not be processed.  If many users are logged on to the Administration, this can lead to a high CPU load. It is advisable to disable the Admin Worker and run the processes server-side via the CLI. In this way, tasks are processed even if no one is logged into the Administration, and a high CPU load due to multiple users is also avoided. This approach is especially useful for larger stores.

Disable Admin Worker & Set-Up CLI Worker

As explained, the use of the Admin Worker is not recommended for production systems. The following section describes how to disable the Admin Worker and run the Message Queue / Scheduled Tasks server-side.

The following settings are made directly on the server. Since the possibilities of the server configuration depend on the hoster, we explain this here generally. If you have questions about the operation of the server configuration, the support of your hoster should be able to help.

Step 1: Change configuration

To disable the admin worker, you have to make the change in the shopware.yaml file. You can find it in your Shopware installation under config/packages/. Disable the admin worker by entering the value "false" and saving the file. Your file should now look like this: 

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

Step 2: Execute CLI commands

For the Message Queue and the Scheduled Tasks to be executed now, the processes must be started via the CLI.


Message Queue:
bin/console messenger:consume default --time-limit=60
Scheduled Tasks:
bin/console scheduled-task:run --time-limit=60

We recommend the parameter time-limit=60 for the above commands to execute the command for a maximum of 60 seconds. Alternatively / additionally, you can define a memory limit instead of a time limit. This is possible with the parameter --memory-limit=512M. More information can be found in our developer doc.

It is important in this process that the commands are executed regularly so that the message queue is continuously processed. This can be achieved, for example, by creating a cron job or a service on the server. Contact your hoster for this.

More information from some hosters

Some hosters provide articles describing how to set up there in their knowledge areas.

Profihost

At Profihost, you can find more information about the setup under https://wissen.profihost.com/wissen/artikel/shopware-6-worker-im-hintergrund-laufen-lassen/

Hetzner

Hetzner provides the information under
https://community.hetzner.com/tutorials/install-shopware-6#step-6---configuring-background-queue-worker

Creoline

Creoline provides the Informationen under
https://help.creoline.com/doc/shopware-6-background-queue-worker-einrichten-XLBEPcGmlt

Timme Hosting

Timme Hosting provides the Informationen under
https://timmehosting.de/shopware-6-admin-worker-deaktivieren

Was this article helpful?