class DelayedRequeueException

Same name and namespace in other branches
  1. 10 core/lib/Drupal/Core/Queue/DelayedRequeueException.php \Drupal\Core\Queue\DelayedRequeueException
  2. 11.x core/lib/Drupal/Core/Queue/DelayedRequeueException.php \Drupal\Core\Queue\DelayedRequeueException

Throw this exception to leave an item in the queue until its lock expires.

Hierarchy

Expanded class hierarchy of DelayedRequeueException

See also

\Drupal\Core\Cron::processQueues() For more information about how this exception interacts with Drupal's Queue operations processing via the built-in cron service.

\Drupal\Core\Queue\DelayableQueueInterface Queues must implement this interface to support custom delay intervals; if this interface is missing, any custom delay interval specified for this exception will be ignored and the remaining time in the original lease will be used as the duration of the delay interval.

\Drupal\Core\Queue\RequeueException For use when an item needs to be requeued immediately.

5 files declare their use of DelayedRequeueException
Cron.php in core/lib/Drupal/Core/Cron.php
CronQueueTestDatabaseDelayException.php in core/modules/system/tests/modules/cron_queue_test/src/Plugin/QueueWorker/CronQueueTestDatabaseDelayException.php
CronQueueTestMemoryDelayException.php in core/modules/system/tests/modules/cron_queue_test/src/Plugin/QueueWorker/CronQueueTestMemoryDelayException.php
CronTest.php in core/tests/Drupal/Tests/Core/CronTest.php
QueueExceptionsTest.php in core/tests/Drupal/Tests/Core/Queue/QueueExceptionsTest.php
1 string reference to 'DelayedRequeueException'
CronTest::processQueuesTestData in core/tests/Drupal/Tests/Core/CronTest.php
Data provider for ::testProcessQueues() method.

File

core/lib/Drupal/Core/Queue/DelayedRequeueException.php, line 19

Namespace

Drupal\Core\Queue
View source
class DelayedRequeueException extends \RuntimeException {
    
    /**
     * The interval of time that the item should remain locked (in seconds).
     *
     * @var int
     */
    protected $delay = 0;
    
    /**
     * Constructs a DelayedRequeueException.
     *
     * @param int $delay
     *   The desired delay interval for this item (in seconds).
     * @param string $message
     *   The error message.
     * @param int $code
     *   The error code.
     * @param \Throwable|null $previous
     *   The previous throwable used for the exception chaining.
     */
    public function __construct(int $delay = 0, string $message = '', int $code = 0, \Throwable $previous = NULL) {
        parent::__construct($message, $code, $previous);
        if ($delay > 0) {
            $this->delay = $delay;
        }
    }
    
    /**
     * Get the desired delay interval for this item.
     *
     * @see self::$delay
     *   For recommended value usage in a queue processor.
     *
     * @return int
     *   The desired delay interval for this item.
     */
    public function getDelay() : int {
        return $this->delay;
    }

}

Members

Title Sort descending Modifiers Object type Summary
DelayedRequeueException::$delay protected property The interval of time that the item should remain locked (in seconds).
DelayedRequeueException::getDelay public function Get the desired delay interval for this item.
DelayedRequeueException::__construct public function Constructs a DelayedRequeueException.

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