function InstantQueueRunner::destruct

Performs destruct operations.

Overrides DestructableInterface::destruct

File

core/lib/Drupal/Core/Queue/InstantQueueRunner.php, line 43

Class

InstantQueueRunner
Provides an instant queue runner that processes items in kernel.destruct.

Namespace

Drupal\Core\Queue

Code

public function destruct() : void {
  foreach ($this->queues as $queue_name => $count) {
    $queue = $this->queueFactory
      ->get($queue_name);
    // Make sure every queue exists. There is no harm in trying to recreate
    // an existing queue.
    $queue->createQueue();
    $worker = $this->queueManager
      ->createInstance($queue_name);
    $count = min($this->config['maximumItems'], $count);
    while ($count) {
      $count--;
      try {
        $claimed = $this->processItem($queue, $worker);
        if (!$claimed) {
          break;

        }
      } catch (SuspendQueueException) {
        break;

      }
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.