Problem/Motivation
On two sites now, I've tried to add items to a queue using a jobtype I created, and I get this error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "advancedqueue_job_type" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
I am at my wits end as I can find no reference to advancedqueue_job_type anywhere.
Steps to reproduce
I installed Advanced Queue.
Created a new queue, "BatchEmbed", machine name "batchembed".
Created a job type:
/src/Plugin/AdvancedQueue/JobType/SolraiAdvancedQueue.php
This is the code:
namespace Drupal\solrai\Plugin\AdvancedQueue\JobType;
use Drupal\advancedqueue\Job;
use Drupal\advancedqueue\JobResult;
use Drupal\advancedqueue\Plugin\AdvancedQueue\JobType\JobTypeBase;
use Drupal\solrai\SolraiEmbedService;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides a job type for embedding Solrai content.
*
* @AdvancedQueueJobType(
* id = "solrai_advanced_queue",
* label = @Translation("Solrai advanced queue"),
* )
*/
class SolraiAdvancedQueue extends JobTypeBase {
/**
* The SolraiEmbedService.
*
* @var \Drupal\solrai\SolraiEmbedService
*/
protected $solraiEmbedService;
/**
* Constructs a new SolraiEmbedSingle.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\solrai\SolraiEmbedService $solrai_embed_service
* The SolraiEmbedService.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, SolraiEmbedService $solrai_embed_service) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->solraiEmbedService = $solrai_embed_service;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
$container->get('solrai.embed_service')
);
}
/**
* {@inheritdoc}
*/
public function process(Job $job) {
$payload = $job->getPayload();
// Call the solrai_embedSingle() method.
$result = $this->solraiEmbedService->solrai_embedSingle(
$payload['solrPrompt'],
$payload['sortField'],
$payload['rows'],
$payload['start'],
$payload['forceUpdate'],
$payload['summarize'],
$payload['questionsOn']
);
// Check the result for the error phrase.
if (strpos($result, 'ERROR:') !== false) {
// An error occurred, return a failure result with the method output.
return JobResult::failure($result);
}
// No error detected, return a successful result.
return JobResult::success();
}
}
In the class method which is attempting to add the queue item, I configure the payload and queue:
$payload = [
'solrPrompt' => $solrPrompt,
'sortField' => $sortField,
'rows' => $rows,
'start' => $start,
'forceUpdate' => $forceUpdate,
'summarize' => $summarize,
'questionsOn' => $questionsOn
];
$queue = \Drupal\advancedqueue\Entity\Queue::load('batchembed');
I then attempt to execute this this:
$job = \Drupal\advancedqueue\Job::create('solrai_advanced_queue', $payload);
$queue->enqueueJob($job);
Which results in this error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "advancedqueue_job_type" entity type does not exist. in Drupal\Core\Entity\EntityTypeManager->getDefinition() (line 139 of core/lib/Drupal/Core/Entity/EntityTypeManager.php).
Following the only tutorial I was able to find in Advanced Queue, it appears that I have created the job type but Advanced Queue is not recognizing it. As it happens consistently across two sites now, it would appear to be a bug.
Proposed resolution
Help me!!!!