protected function PullController::processQueue in Salesforce Suite 8.3
Same name and namespace in other branches
- 8.4 modules/salesforce_pull/src/Controller/PullController.php \Drupal\salesforce_pull\Controller\PullController::processQueue()
- 5.0.x modules/salesforce_pull/src/Controller/PullController.php \Drupal\salesforce_pull\Controller\PullController::processQueue()
1 call to PullController::processQueue()
- PullController::endpoint in modules/
salesforce_pull/ src/ Controller/ PullController.php - Page callback to process push queue for a given mapping.
File
- modules/
salesforce_pull/ src/ Controller/ PullController.php, line 189
Class
- PullController
- Push controller.
Namespace
Drupal\salesforce_pull\ControllerCode
protected function processQueue() {
$start = microtime(true);
$worker = $this->queueWorkerManager
->createInstance(QueueHandler::PULL_QUEUE_NAME);
$end = time() + $this
->getTimeLimit();
$queue = $this->queueService
->get(QueueHandler::PULL_QUEUE_NAME);
$count = 0;
while ((!$this
->getTimeLimit() || time() < $end) && ($item = $queue
->claimItem())) {
try {
$this->eventDispatcher
->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Processing item @id from @name queue.', [
'@name' => QueueHandler::PULL_QUEUE_NAME,
'@id' => $item->item_id,
]));
$worker
->processItem($item->data);
$queue
->deleteItem($item);
$count++;
} catch (RequeueException $e) {
// The worker requested the task to be immediately requeued.
$queue
->releaseItem($item);
} catch (SuspendQueueException $e) {
// If the worker indicates there is a problem with the whole queue,
// release the item.
$queue
->releaseItem($item);
throw new \Exception($e
->getMessage());
}
}
$elapsed = microtime(true) - $start;
$this->eventDispatcher
->dispatch(SalesforceEvents::NOTICE, new SalesforceNoticeEvent(NULL, 'Processed @count items from the @name queue in @elapsed sec.', [
'@count' => $count,
'@name' => QueueHandler::PULL_QUEUE_NAME,
'@elapsed' => round($elapsed, 2),
]));
}