class QueueWorker in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/lib/Drupal/Core/Annotation/QueueWorker.php \Drupal\Core\Annotation\QueueWorker
Declare queue workers that need to be run periodically.
While there can be only one hook_cron() process running at the same time, there can be any number of processes defined here running. Because of this, long running tasks are much better suited for this API. Items queued in hook_cron() might be processed in the same cron run if there are not many items in the queue, otherwise it might take several requests, which can be run in parallel.
You can create queues, add items to them, claim them, etc. without using a QueueWorker plugin if you want, however, you need to take care of processing the items in the queue in that case. See \Drupal\Core\Cron for an example.
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
Expanded class hierarchy of QueueWorker
See also
\Drupal\Core\Queue\QueueWorkerInterface
\Drupal\Core\Queue\QueueWorkerBase
\Drupal\Core\Queue\QueueWorkerManager
Related topics
4 classes are annotated with QueueWorker
- AggregatorRefresh in core/
modules/ aggregator/ src/ Plugin/ QueueWorker/ AggregatorRefresh.php - Updates a feed's items.
- CronQueueTestBrokenQueue in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestBrokenQueue.php - Plugin annotation @QueueWorker( id = "cron_queue_test_broken_queue", title = @Translation("Broken queue test"), cron = {"time" = 60} )
- CronQueueTestException in core/
modules/ system/ tests/ modules/ cron_queue_test/ src/ Plugin/ QueueWorker/ CronQueueTestException.php - Plugin annotation @QueueWorker( id = "cron_queue_test_exception", title = @Translation("Exception test"), cron = {"time" = 60} )
- LocaleTranslation in core/
modules/ locale/ src/ Plugin/ QueueWorker/ LocaleTranslation.php - Executes interface translation queue tasks.
File
- core/
lib/ Drupal/ Core/ Annotation/ QueueWorker.php, line 38 - Contains \Drupal\Core\Annotation\QueueWorker.
Namespace
Drupal\Core\AnnotationView source
class QueueWorker extends Plugin {
/**
* The plugin ID.
*
* @var string
*/
public $id;
/**
* The human-readable title of the plugin.
*
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation
*/
public $title;
/**
* An associative array containing the optional key:
* - time: (optional) How much time Drupal cron should spend on calling
* this worker in seconds. Defaults to 15.
*
* @var array (optional)
*/
public $cron;
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Plugin:: |
protected | property | The plugin definition read from the class annotation. | 1 |
Plugin:: |
public | function |
Gets the value of an annotation. Overrides AnnotationInterface:: |
2 |
Plugin:: |
public | function |
Gets the class of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function |
Gets the unique ID for this annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function |
Gets the name of the provider of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
protected | function | Parses an annotation into its definition. | |
Plugin:: |
public | function |
Sets the class of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function |
Sets the name of the provider of the annotated class. Overrides AnnotationInterface:: |
|
Plugin:: |
public | function | Constructs a Plugin object. | 1 |
QueueWorker:: |
public | property | An associative array containing the optional key: | |
QueueWorker:: |
public | property | The plugin ID. | |
QueueWorker:: |
public | property | The human-readable title of the plugin. |