Declare a worker class for processing a queue item.
Worker plugins are used by some queues for processing the individual items in the queue. In that case, the ID of the worker plugin needs to match the machine name of a queue, so that you can retrieve the queue back end by calling \Drupal\Core\Queue\QueueFactory::get($plugin_id).
\Drupal\Core\Cron::processQueues() processes queues that use workers; they can also be processed outside of the cron process.
Some queues do not use worker plugins: you can create queues, add items to them, claim them, etc. without using a QueueWorker plugin. However, you will need to take care of processing the items in the queue in that case. You can look at \Drupal\Core\Cron::processQueues() for an example of how to process a queue that uses workers, and adapt it to your queue.
Plugin Namespace: Plugin\QueueWorker
For a working example, see \Drupal\aggregator\Plugin\QueueWorker\AggregatorRefresh.
Hierarchy
- class \Drupal\Component\Annotation\Plugin implements AnnotationInterface
- class \Drupal\Core\Annotation\QueueWorker
See also
\Drupal\Core\Queue\QueueWorkerInterface
\Drupal\Core\Queue\QueueWorkerBase
\Drupal\Core\Queue\QueueWorkerManager
Plugin API
Related topics
- Annotations
- Annotations for class discovery and metadata description.
File
- core/lib/Drupal/Core/Annotation/QueueWorker.php, line 36
Namespace
Drupal\Core\Annotation
Members
Name | Modifiers | Type | Description |
---|---|---|---|
Plugin::$definition | protected | property | The plugin definition read from the class annotation. |
Plugin::get | public | function | Gets the value of an annotation. Overrides AnnotationInterface::get |
Plugin::getClass | public | function | Gets the class of the annotated class. Overrides AnnotationInterface::getClass |
Plugin::getId | public | function | Gets the unique ID for this annotated class. Overrides AnnotationInterface::getId |
Plugin::getProvider | public | function | Gets the name of the provider of the annotated class. Overrides AnnotationInterface::getProvider |
Plugin::parse | protected | function | Parses an annotation into its definition. |
Plugin::setClass | public | function | Sets the class of the annotated class. Overrides AnnotationInterface::setClass |
Plugin::setProvider | public | function | Sets the name of the provider of the annotated class. Overrides AnnotationInterface::setProvider |
Plugin::__construct | public | function | Constructs a Plugin object. |
QueueWorker::$cron | public | property | An associative array containing the optional key: |
QueueWorker::$id | public | property | The plugin ID. |
QueueWorker::$title | public | property | The human-readable title of the plugin. |
Please login to continue.