This example demonstrates how to use the queue API.

The queue API provides a traditional FIFO (first-in-first-out) queue, but also provides the concepts of:

  • "Creating" a queued item, which means inserting it into a queue.
  • "Claiming" a queued item, which essentially means requesting the next item from the queue and holding a lock on that item for a specified period of time.
  • "Releasing" an item, which means giving up a claim but leaving the item in the queue.
  • "Deleting" an item, which means finally removing it from the queue.

This example demonstrates only basic queue functionality; it will use the default queue implementation, which is SystemQueue, that uses the persistent database storage.

Further resources include the limited Queue operations documentation and Batch vs. Queue: an API Smackdown by John VanDyk.

See also

system.queue.inc

Parent topics

File

modules/examples/queue_example/queue_example.module, line 7
Hook implementations for the Queue Example module.

Functions

Namesort descending Location Description
queue_example_add_remove_form modules/examples/queue_example/queue_example.module Form generator for managing the queue.
queue_example_add_remove_form_claim modules/examples/queue_example/queue_example.module Submit function for the "claim" button.
queue_example_add_remove_form_clear_queue modules/examples/queue_example/queue_example.module Submit handler for clearing/deleting the queue.
queue_example_add_remove_form_delete modules/examples/queue_example/queue_example.module Submit function for "Claim and delete" button.
queue_example_add_remove_form_insert modules/examples/queue_example/queue_example.module Submit function for the insert-into-queue button.
queue_example_add_remove_form_run_cron modules/examples/queue_example/queue_example.module Submit function for "run cron" button.
queue_example_menu modules/examples/queue_example/queue_example.module Implements hook_menu().
queue_example_retrieve_queue modules/examples/queue_example/queue_example.module Retrieves the queue from the database for display purposes only.
queue_example_show_queue modules/examples/queue_example/queue_example.module Submit function for the show-queue button.
queue_example_theme modules/examples/queue_example/queue_example.module Implements hook_theme().
theme_queue_items modules/examples/queue_example/queue_example.module Themes the queue display.

Classes

Namesort descending Location Description
QueueExampleTestCase modules/examples/queue_example/tests/queue_example.test Functional tests for the Queue Example module.