Author:
Source
Creating queues using the core queue classes in Drupal is fairly straightforward. You just need a mechanism of adding data to the queue and a worker to process that data.
As the data you add to the queue is serialised you can add pretty much any data you want to the queue, so the only limitation is rebuilding the data once you pull it out of the queue.
There are some situations where the core Drupal queue system needs to be altered in some way. You might want to separate the data into different tables, or have a different logic for creating or storing the queue items, or even integrate with a third party queue system for manage the queues.
Whilst all of these examples are possible, they require a certain amount of understanding of the queue API and need additional services and settings to get working.
In this article we will look at how to create a custom queue, along with the queue factory needed to integrate that queue with Drupal. We will also look at some settings needed to swap out certain queues for you custom queue implementations. All of the code seen in this article is available in our Drupal Queue Examples repository on GitHub, specifically the queue_custom_example module.
First, let’s look at what is requires for a queue to work in Drupal.
Create A Custom Queue With The QueueInterface Interface
The interface DrupalCoreQueueQueueInterface is used to build the framework of the queue, which is used to manage the queue items. Your queue object must have the following methods.
philipnorton42
Sun, 01/19/2025 – 19:54