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.

Scheduled task available by default

Scheduled TaskRun interval (seconds)Explanation
log_entry.cleanup86400Empties the "log_entry" table
shopware.invalidate_cache20Invalidation of the cache
app_update86400Checks whether there is an update for the installed extensions
app_delete86400Manually removes an extension and the associated plugin data from the Shopware database and the server files
version.cleanup86400Deletes outdated version IDs from the database
webhook_event_log.cleanup86400Deletes webhook event logs that are older than the set time
sales_channel_context.cleanup86400Empties the "sales_channel_context" table
product_keyword_dictionary.cleanup604800Empties the "product_keyword_dictionary" table
product_download.media.cleanup2628000Deletes unassigned images
delete_newsletter_recipient_task86400Deletes all unconfirmed newsletter recipients whose registration attempt was more than 30 days ago.
product_stream.mapping.update86400Updates the mapping of dynamic product groups
product_export_generate_task60Triggers the product export
import_export_file.cleanup86400Empties the "import_export_file" table
shopware.sitemap_generate86400Generates the sitemap
cart.cleanup86400Deletes all shopping carts that are older than 120 (shopware.cart.expire_days) days.
shopware.elasticsearch.create.alias300Triggers the creation of Elastic Search Alias, this is only executed when required.

Some tasks such as shopware.elasticsearch.create.alias and shopware.invalidate_cache are only executed on demand. The Elasticsearch task is only executed if an Elasticsearch server is configured and activated.

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.

CLI-Worker

The CLI Worker is a service that can be set up directly on the server. It is used for executing background jobs, where "CLI" stands for "Command Line Interface," meaning it can perform tasks via the command line. The CLI Worker handles tasks such as executing indexings and other processes that do not need to occur directly in the frontend of the Shopware admin. Commands can also be set up as cron jobs, allowing them to be regularly performed in the background.

You can find more information in our developer-documentation.

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 so that the change is also update-safe. You can find it in your Shopware installation under config/packages/. If the file is missing, please create it.

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 async low priority --time-limit=60

It is important to note that the command has changed as of Shopware version 6.5. The old CLI command with the value "default" will fail.

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.

Step 3: Choose Execution Method (Cronjob or as a Service)

In the next step, you should decide how you want to process the message queue. You can set up the above commands as a cronjob or configure the CLI worker as a service.

You can find more information about this here.

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?