Queue API
Component ID
Component name
Component type
Maintenance status
Development status
Component security advisory coverage
Component created
Component changed
Component body
This module aims to simplify the processing of Drupal queues by providing a controller API for the processing of complex ones.
The module also will provide batch processing bindings for queues managed by the module.
This will allow developers to process a queues seamlessly on cron and/or batch operations.
The process for using this utility:
1. Implement the your module's queue controller by extending the QueueApiController base class.
2. Add your controller class in your module's info files[] array
3. Define a queue with the hook_cron_queue_info().
4. In the new queue definition, add the new controller class.
Tips:
1. I find it a bit easier to have a constant for the queue name, as it is used extensively in the API.
define('YOUR_MODULE_QUEUE_NAME_1', 'some-queue-name');
2. When you want to use the API only for batch processing it is recommended to define the property on the queues to skip processing on cron to TRUE.
Code examples:
Full usage of the API can be found in the queue_api_example sub-module.
1. Enqueue items on cron:
function MY_MODULE_cron() {
QueueApi::get(YOUR_MODULE_QUEUE_NAME_1)->init();
}
2 . Implement a queue worker callback:
If this patch is applied, you can define the queue item through the utility class and this will allow you to omit the queue worker definition (To be implemented).
function _MY_MODULE_queue_1_worker_callback($item) {
QueueApi::get(YOUR_MODULE_QUEUE_NAME_1)->dispatch($item);
}
3. Process the queue on a batch on form submit:
QueueApi::batchProcess(YOUR_MODULE_QUEUE_NAME_1, array(
'param1' => 'value1',
));
