By default, commands execute on a “synchronous” transport – meaning the moment that Concrete executes them the business of the command operates. Developers can control how these commands operate, whether at the command level or the execution level. If a command executes asynchronously, it will be added into the default queue. By default, jobs added to the default queue are processed sequentially whenever an administrator is using the Dashboard. They are processed in the background. For much more performant and reliable processing, you can enable the manual queue listener.
Implementing Asynchronous Commands
Use the AsyncCommandInterface
If your command classes implement the Concrete\Core\Foundation\Command\AsyncCommandInterface
class it will be processed via the default asynchronous transport. This interface has no methods – it's simply an indication to Concrete that you’d like this command to be processed asynchronously.
Use Configuration
You can use configuration to determine which transport (asynchronous or synchronous) via configuration as well. This is done using the concrete.messenger.routing
configuration. Just add the following to your application/config/concrete.php
file to route the clear cache command to the asynchronous transport:
'messenger' => [
'routing' => [
'Concrete\Core\Cache\Command\ClearCacheCommand' => ['async'],
],
],