-
Notifications
You must be signed in to change notification settings - Fork 9
Grouping jobs
Code Slicer edited this page Jun 13, 2022
·
3 revisions
Now (since v3.1) you can also optionally group your jobs by giving them an identifier. That way you can know easily what is happening with jobs of service x or y whenever you want.
To use this feature, instead of the default ->append(...$params)
method, you can use the brand new ->appendToGroup("groupd_identifier", ...$params)
one, like this:
<?php declare(strict_types=1);
namespace YourCompany\YourModule\Observer;
use Discorgento\Queue\Api\QueueManagementInterface;
use Magento\Framework\Event;
class ProductSaveAfter implements Event\ObserverInterface
{
private QueueManagementInterface $queueManagement;
public function __construct(
QueueManagementInterface $queueManagement
) {
$this->queueManagement = $queueManagement;
}
/** @inheritDoc */
public function execute(Event\Observer $observer) {
$this->queueManagement->appendToGroup(
'pim', // specify a group for easier identification later on grid
\YourCompany\YourModule\Job\SyncProduct::class,
$observer->getProduct()->getId()
);
}
}
With that, you'll be able to filter the jobs per service on queue management grid later:
We want YOU for our community 🫵