I have a cron job that calls a queueworker to process items. In the cron function, I'd like to perform some more action on the data once the items have been processed. How can I tell that the queue is complete? Should I do a separate cron for that task?

Current logic in cron function:

  1. (CRON) There is a content type that has a field (updated) to track if the node is updated or not. So, for all nodes of this content type, set the updated field to FALSE.
  2. (CRON) Retrieve data from an external table, for each row, put into QueueWorker to process.
  3. (QUEUEWORKER) In the QueueWorker, check to see if there is a node already for this row, if not, create new node. If node exists, update it. For both, set updated field to TRUE and save node.
  4. (CRON) After all the rows have been processed in the queue, go back to get all nodes of the content type, and find all the ones where the updated field has NOT been set to TRUE and delete them.

Because steps #3 is a queue process, the items get processed as a separate 'thread'. This means item #4 is completed before the items are actually processed. My question is, how do I perform step #4 AFTER all the rows have been processed in QueueWorker? Should I create a separate cron job for the node deletion?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.