The Export Queue module facilitates setting up any number of export queues on a site. An export queue functions as a waiting list of objects requiring export to a third party application, like orders in an e-commerce site being exported to a fulfillment service. The module provides a single database table to track queued items and offers a simple API for other modules to define export queues, enqueue items, and update them upon export. It is designed to be used either to track objects awaiting export on a cron run, as a way to store up items for batch exports, or as a fallback measure in the event of a failed real-time export.

Administrators have the ability to adjust export limits and cron URLs for the various queues, and they may also view reports of all the objects that have been queued and exported through any given export queue.

This module is a utility module that only needs to be installed when required by another module.

Current Status

This module is not currently ready for use but will be in the next day or two. At this point, it's mainly lacking the various API functions needed to enqueue items and update items in the queue. The reports are also currently non-existent. I've designed several export systems in the past and desired a utility module that I can use to avoid having to redesign features like custom cron URLs, batch processing, fallback systems, etc. for each one. As I'm developing this module alongside another export implementation, you can expect this to reach a usable point fairly quickly.

I'll be documenting as I go along on this page until the module is complete and the documentation is moved into the Drupal handbook. I will not be writing update functions until I package up an official release. Development is underway in the DRUPAL-6--1 branch.

Documentation

The administrative user interface is fairly straightforward. Browsing to Administer > Site configuration > Export queues will display some basic general settings for export queues and a list of fieldsets for the various export queues on your site. You can disable exports for any given queue, choose between exporting through the site-wide cron or a custom cron URL, and adjust how many items will be exported on a cron run. The module lets you use custom cron URLs to facilitate your desired export schedule.

Complete developer documentation is forthcoming. For now, the following should get you started.

Define export queues by implementing hook_export_queue(). This hook expects you to return an associative array of queues, the key being the queue's ID (using only alphanumeric characters, hyphens, and underscores) and the value being an associative array of queue data. Queue arrays may contain values the following keys:

  • name => The human readable name of the export queue.
  • description => A human readable description of the purpose of the export queue.
  • callback => The callback function used for actually preparing and exporting the data.
  • enabled (optional) => TRUE or FALSE indicating that this export queue is active; defaults to TRUE. Even when FALSE, items may be queued for export; the queue just won't actually be processed on the cron run.
  • cron (optional) => Either 'site' or 'custom' indicating whether this export queue will be processed on the site-wide cron run or through a custom cron URL specific to this queue.
  • cron_limit => The default number of items exported on the cron run.
  • batch_limit (optional) => The number of batched items the export service can accept in a single API request; leave undefined or set to 0 if an export service does not support batching (i.e. one API request per item), a positive integer if there is a limit to batched API requests, or -1 to indicate that a service can accept any number of batched items at a time.

Example implementation:

<?php
/**
* Implementation of hook_export_queue().
*/
function example_export_queue() {
 
$queues = array();
 
$queues['order_fulfillment'] = array(
   
'name' => t('Order fulfillment service'),
   
'description' => t('Export orders to a generic order fulfillment service.'),
   
'callback' => 'order_fulfillment_export',
   
'cron_limit' => 50,
   
'batch_limit' => 250,
  );
  return
$queues;
}
?>

Export queue callbacks should expect a single argument, an associative array describing items to be exported keyed by their queue ID. The callback function is responsible for loading the objects referenced by the object_id and generating appropriate API requests to export the data. Upon successful export, the callback function is expected to update the information for the data for the item in the export queue to record the success. If an export fails, the callback function should notify the export queue module using the __(currently undefined)__ API function so the failure may be logged as required by the module's settings.

Credits

Sponsors

Project Information

  • Maintenance status: Unknown
  • Development status: Unknown
  • Module categories: Developer, Utility
  • Reported installs: 1 site currently reports using this module. View usage statistics.
  • Downloads: 344
  • Last modified: July 23, 2009

Downloads