A new DelayedRequeueException allows a queue worker to delay further processing of an item until its next cycle or by setting a custom delay before a queue item's lock expires. Queue support for custom delay intervals is contingent on the queue implementing a new DelayableQueueInterface.
Previously, it wasn't possible to delay the processing of a single item without throwing an exception that would incur error logging or suspending an entire queue. The new exception handling behavior is silent by default and allows a single item to be delayed in a queue.
\Drupal\Core\Queue\DelayedRequeueException can be thrown from a queue worker to add a delay to an item:
// Delay processing of this item until the next queue worker cycle.
throw new DelayedRequeueException();
// Delay processing of this item for 10 seconds (if supported by the queue).
throw new DelayedRequeueException(10);
Queues that want to support custom delay intervals can implement the new \Drupal\Core\Queue\DelayableQueueInterface. If a queue doesn't implement this new interface, any custom delay interval will be ignored and items will remain locked for the duration of their original lease if a DelayedRequeueException is thrown.
Queues that implement DelayableQueueInterface should delay processing of items for at least one cycle if a DelayedRequeueException is thrown without a custom delay interval (i.e. an interval of zero).
\Drupal\Core\Queue\DatabaseQueue now implements the new DelayableQueueInterface.