class JobSchedulerQueue in Job Scheduler 8.2
Same name and namespace in other branches
- 8.3 src/Plugin/QueueWorker/JobSchedulerQueue.php \Drupal\job_scheduler\Plugin\QueueWorker\JobSchedulerQueue
Providing our own worker has the advantage that we can reschedule the job or take care of cleanup. Note that as we run the execute() action, the job won't be queued again this time.
Plugin annotation
@QueueWorker(
id = "job_scheduler_queue",
title = @Translation("Job Scheduler Queue"),
cron = {"time" = 60},
deriver = "Drupal\job_scheduler\Plugin\Derivative\JobSchedulerQueueWorker"
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\job_scheduler\Plugin\QueueWorker\JobSchedulerQueue
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of JobSchedulerQueue
File
- src/
Plugin/ QueueWorker/ JobSchedulerQueue.php, line 19
Namespace
Drupal\job_scheduler\Plugin\QueueWorkerView source
class JobSchedulerQueue extends QueueWorkerBase {
/**
* The name of this scheduler.
*
* @var \Drupal\job_scheduler\JobScheduler
*/
protected $scheduler;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->scheduler = \Drupal::service('job_scheduler.manager');
}
/**
* {@inheritdoc}
*/
public function processItem($job) {
$scheduler = $this->scheduler;
try {
$scheduler
->execute($job);
} catch (\Exception $e) {
watchdog_exception('job_scheduler', $e);
// Drop jobs that have caused exceptions.
$scheduler
->remove($job);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
JobSchedulerQueue:: |
protected | property | The name of this scheduler. | |
JobSchedulerQueue:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
JobSchedulerQueue:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. |