QueueWorkerInterface.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace Drupal\Core\Queue;
  3. use Drupal\Component\Plugin\PluginInspectionInterface;
  4. /**
  5. * Defines an interface for a QueueWorker plugin.
  6. *
  7. * @see \Drupal\Core\Queue\QueueWorkerBase
  8. * @see \Drupal\Core\Queue\QueueWorkerManager
  9. * @see \Drupal\Core\Annotation\QueueWorker
  10. * @see plugin_api
  11. */
  12. interface QueueWorkerInterface extends PluginInspectionInterface {
  13. /**
  14. * Works on a single queue item.
  15. *
  16. * @param mixed $data
  17. * The data that was passed to
  18. * \Drupal\Core\Queue\QueueInterface::createItem() when the item was queued.
  19. *
  20. * @throws \Drupal\Core\Queue\RequeueException
  21. * Processing is not yet finished. This will allow another process to claim
  22. * the item immediately.
  23. * @throws \Exception
  24. * A QueueWorker plugin may throw an exception to indicate there was a
  25. * problem. The cron process will log the exception, and leave the item in
  26. * the queue to be processed again later.
  27. * @throws \Drupal\Core\Queue\SuspendQueueException
  28. * More specifically, a SuspendQueueException should be thrown when a
  29. * QueueWorker plugin is aware that the problem will affect all subsequent
  30. * workers of its queue. For example, a callback that makes HTTP requests
  31. * may find that the remote server is not responding. The cron process will
  32. * behave as with a normal Exception, and in addition will not attempt to
  33. * process further items from the current item's queue during the current
  34. * cron run.
  35. *
  36. * @see \Drupal\Core\Cron::processQueues()
  37. */
  38. public function processItem($data);
  39. }