Queue operations

  1. drupal
    1. drupal7

The queue system allows placing items in a queue and processing them later. The system tries to ensure that only one consumer can process an item.

Before a queue can be used it needs to be created by DrupalQueueInterface::createQueue().

Items can be added to the queue by passing an arbitrary data object to DrupalQueueInterface::createItem().

To process an item, call DrupalQueueInterface::claimItem() and specify how long you want to have a lease for working on that item. When finished processing, the item needs to be deleted by calling DrupalQueueInterface::deleteItem(). If the consumer dies, the item will be made available again by the DrapalQueueInterface implementation once the lease expires. Another consumer will then be able to receive it when calling DrupalQueueInterface::claimItem().

The $item object used by the DrupalQueueInterface can contain arbitrary metadata depending on the implementation. Systems using the interface should only rely on the data property which will contain the information passed to DrupalQueueInterface::createItem(). The full queue item returned by DrupalQueueInterface::createItem() needs to be passed to DrupalQueueInterface::deleteItem() once processing is completed.

While the queue system makes a best effort to preserve order in messages, due to the pluggable nature of the queue, there is no guarantee that items will be delivered on claim in the order they were sent. For example, some implementations like beanstalkd or others with distributed back-ends like Amazon SQS will be managing jobs for a large set of producers and consumers where a strict FIFO ordering will likely not be preserved.

The system also makes no guarantees about a task only being executed once: callers that have non-idempotent tasks either need to live with the possiblity of the task being invoked multiple times in cases where a claim lease expires, or need to implement their own transactions to make their tasks idempotent.

Klassen

NameBeschreibung
DrupalQueueFactory class for interacting with queues.
SystemQueueDefault queue implementation.

Funktionen & Methoden

NameBeschreibung
getGet a queue object for a given name.
claimItemClaim an item in the queue for processing.
createItemAdd a queue item and store it directly to the queue.
createQueueCreate a queue.
deleteItemDelete a finished item from the queue.
deleteQueueDelete a queue and every item in the queue.
numberOfItemsRetrieve the number of items in the queue.
__constructStart working with a queue.
claimItem
createItem
createQueue
deleteItem
deleteQueue
numberOfItems
__construct

Interfaces

NameBeschreibung
DrupalQueueInterface

Properties

NameBeschreibung
/** * Our internal consumer ID for this queue instance. * * This is created lazily when we start consuming items with claimItem(). * * @var integer */ protected $consumerIdOur internal consumer ID for this queue instance.
/** * The name of the queue this instance is working with. * * @var string */ protected $nameThe name of the queue this instance is working with.

modules/system/system.queue.inc, line 9

Kommentare

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen

Kommentar hinzufügen

Der Inhalt dieses Feldes wird nicht öffentlich zugänglich angezeigt.
  • Internet- und E-Mail-Adressen werden automatisch umgewandelt.
  • Zulässige HTML-Tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Zeilen und Absätze werden automatisch erzeugt.

Weitere Informationen über Formatierungsoptionen