Process Queue
Process Queue
Section titled “Process Queue”Type: queue-process · Package: Queue Activities v1.0.0 · Output: —
A container activity (like For Each) that drains a queue for you: on each turn it takes the next item with an atomic lock, runs the body you define with the item in scope, and sets the result automatically (successful if the body finishes, failed if it throws). It repeats until the queue is empty.
It is the consumer (performer) pattern in a single activity: it encapsulates the While + Get Queue Item + Try/Catch + Set Transaction Status loop so you don’t have to wire it by hand every time.
How it works
Section titled “How it works”On each iteration:
- Takes the next item from the queue (atomic, locks it for this execution). If the queue is empty, the loop ends.
- Exposes the item in the variable you choose (
itemVariable, typedZoanQueueItem). - Runs the body (your sub-activities).
- Reports the status automatically:
- the body finishes without error →
successful; - the body throws an exception →
failed(honors the queue’sauto_retry).
- the body finishes without error →
- Goes back to step 1.
Required parameters
Section titled “Required parameters”| Parameter | Editor | Description |
|---|---|---|
queueName | expression | Queue name. It must exist in the execution environment. |
itemVariable | identifier | Name of the variable that receives the current item (ZoanQueueItem). |
activities | body | The activities that run for each item. |
Optional parameters
Section titled “Optional parameters”| Parameter | Editor | Description |
|---|---|---|
maxItems | number | Maximum number of items to process. Empty = until the queue is empty. |
onError | list | On a failing item: continue (mark it failed and go to the next one — default) or stop (mark it failed and stop the loop). |
Example
Section titled “Example”The full performer, in a single block:
Process Queue queueName = "facturas-por-validar" itemVariable = item onError = continue └─ body: (… process = item.SpecificContent["facturaId"] …) Set Variable validated = trueYou don’t need While, a null check, Try/Catch, or to close the transaction: if the body finishes, the item is left successful; if something inside throws, it is left failed and the loop continues with the next one.
Manual equivalent
Section titled “Manual equivalent”Process Queue does exactly this for you:
While condition = =true └─ body: Get Queue Item queueName = "facturas-por-validar" → output: item If condition = =item == null └─ then: Break Try └─ body: (… process …) · Set Transaction Status item = =item status = successful └─ catch: Set Transaction Status item = =item status = failedUse the manual form only if you need fine control (batches, custom retries, postponing with Postpone Transaction).
Related activities
Section titled “Related activities”- Get Queue Item — take items one at a time (the primitive it uses internally).
- Set Transaction Status — report success or failure manually.
- Postpone Transaction — postpone an item until later.
- Add Queue Item — enqueue work (the producer side).