Skip to content
  1. Extras
  2. simpleQueue

simpleQueue

A simple message queue for use in any third-party components.

A message queue is useful when you need to add a message about a new action in one process and handle it in another.

Example: sending emails. In the main process you add a message about a new outgoing email, and a separate script performs the actual send.

Can be used both at the object level and at the processor level.

Connecting the service

Standard call:

php
sq = $this->modx->getService(
    'simplequeue',
    'simpleQueue',
    $this->modx->getOption('simplequeue_core_path', null, $this->modx->getOption('core_path') . 'components/simplequeue/') . 'model/simplequeue/',
    array()
);

Short call:

php
$sq = $modx->getService('simplequeue');

For the short call to work, run this once (e.g. in Console):

php
$modx->addExtensionPackage('simplequeue', '[[++core_path]]components/simplequeue/model/');

Objects

Class sqMessage

FieldPurposeAuto-filled?
idIDYes
serviceArbitrary name of the service that added the messageNo
actionArbitrary name of the action to performNo
subjectDetails for the action, e.g. ID of the object to processNo
createdonCreation time, filled automaticallyYes
createdbyID of the user who created the messageYes
processedCompletion flag (bool)No
statusStatus set by the serviceNo
propertiesJSON array with arbitrary dataNo

Class sqLog

FieldPurposeAuto-filled?
idIDYes
message_idID of the modified messageYes
user_idID of the user who modified the messageYes
timestampChange timestampYes
operationAction performedYes
entryJSON array with changed fields and their valuesNo

Processors

The component includes message processors:

ProcessorPurposeParameters
createCreateservice, action, subject, properties
updateUpdateid, status, properties
closeCloseid
openReopenid
getGet oneid
getlistGet listids

Example processor call:

php
$response = $modx->runProcessor(
    'message/update',
    array('id' => 1, 'status' => '5'),
    array('processors_path' => MODX_CORE_PATH . 'components/simplequeue/processors/');
);

When using processors, sqLog entries are created automatically and store message state after save.