Skip to content

Queue

Version: 1.0.0  ·  ID: zoan-packages-queue  ·  Author: Zoan Software

The Queue package allows bots to work with Zoan Cloud work queues: lists of pending tasks that are processed one by one, with atomic locking, retries and priorities. It is the RPA pattern for processing large batches robustly and in parallel.

ActivityTypeOutputWhat it does
Add Queue Itemqueue-add-itemZoanQueueItemEnqueue a new item with its payload
Add Transaction Itemqueue-add-transaction-itemZoanQueueItemCreate an item and return it already in_progress locked (create + process in the same run)
Get Queue Itemqueue-get-itemZoanQueueItemTake (and block) the next item; null if queue is empty
Process Queuequeue-processDrains the whole queue: takes each item, runs your logic and reports the result (the performer in a single activity)
Set Transaction Statusqueue-set-transaction-statusMark an item as successful or failed
Postpone Transactionqueue-postpone-transactionReturns the item to the queue and defers it (without counting the attempt)

The Add Queue Item and Get Queue Item activities return ZoanQueueItem. Your most used fields, accessible from expressions:

FieldTypePurpose
item.IdtextUnique identifier — you need it to report the status.
item.ReferencetextThe reference given by the producer (if there was one).
item.StatustextEstado actual (new, in_progress, successful…).
item.SpecificContent["campo"]objetoThe payload: the data that the bot must process.
item.Prioritytexthigh, normal o low.
item.AttemptsnumberHow many attempts have been made on this item.
item.OutputobjetoThe saved result (if it finished successfully).
item.ExceptionobjetoThe detail of the error (if it failed).

For example, if you queued the payload with a facturaId field, inside the performer you read it like this: = item.SpecificContent["facturaId"].

The normal thing is two playbooks (which you publish as two processes).

It goes through the data source and queues an item for each work unit. It is usually launched with a programmed trigger.

Read Range archivo = "facturas.xlsx" → output: facturas
For Each item en = facturas.Rows
└─ body:
Add Queue Item
queueName = "facturas-por-validar"
reference = = item["numero"]
specificContent = {
"facturaId": = item["numero"],
"monto": = item["monto"]
}

The reference (optional) makes the enqueue idempotent: if you enqueue the same reference again, Zoan Cloud returns the existing item instead of creating a duplicate. Useful if the dispatcher runs twice.

In a loop, it takes items until the queue is empty, processes each one and reports the result within a Try / Catch.

While condition = true
└─ body:
Get Queue Item queueName = "facturas-por-validar" → output: item
If condition = = item == null
└─ then: Break (la cola está vacía → salir del bucle)
Try
└─ body:
(… procesa = item.SpecificContent["facturaId"] …)
Set Transaction Status item = = item status = successful
output = { "validada": true }
└─ catch (err):
Set Transaction Status item = = item status = failed
exception = { "message": = err.Message }