delayItem example


  public function testDatabaseQueueReturnTypes(): void {
    /** @var \Drupal\Core\Queue\DatabaseQueue $queue */
    $queue = $this->container
      ->get('queue')
      ->get('cron_queue_test_database_delay_exception');
    static::assertInstanceOf(DatabaseQueue::class$queue);

    $queue->createItem(12);
    $item = $queue->claimItem();
    static::assertTrue($queue->delayItem($item, 1));
    static::assertTrue($queue->releaseItem($item));
    $queue->deleteItem($item);
    static::assertFalse($queue->delayItem($item, 1));
    static::assertFalse($queue->releaseItem($item));
  }

  /** * Test safeguard against invalid annotations in QueueWorkerManager. */
  public function testQueueWorkerManagerSafeguard(): void {
    $queue_worker_manager = $this->container->get('plugin.manager.queue_worker');
    
$queue->deleteItem($item);
      }
      catch (DelayedRequeueException $e) {
        // The worker requested the task not be immediately re-queued.         // - If the queue doesn't support ::delayItem(), we should leave the         // item's current expiry time alone.         // - If the queue does support ::delayItem(), we should allow the         // queue to update the item's expiry using the requested delay.         if ($queue instanceof DelayableQueueInterface) {
          // This queue can handle a custom delay; use the duration provided           // by the exception.           $queue->delayItem($item$e->getDelay());
        }
      }
      catch (RequeueException) {
        // The worker requested the task be immediately requeued.         $queue->releaseItem($item);
      }
      catch (SuspendQueueException $e) {
        // If the worker indicates the whole queue should be skipped, release         // the item and go to the next queue.         $queue->releaseItem($item);

        
Home | Imprint | This part of the site doesn't use cookies.