Dequeue
Removes and returns the first element from an in-memory queue. Elements are retrieved in FIFO (First-In-First-Out) order - the first item added is the first item removed.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing the node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
If the ContinueOnError property is true, no error is caught when the project is executed, even if a Catch node is used.
Inputs
- Queue ID - The unique queue identifier returned from the Create Queue node.
Output
- Element - The element removed from the front of the queue. The data type matches the type that was enqueued (string, object, array, etc.).
How It Works
The Dequeue node removes and returns the first element from the specified queue. When executed, the node:
- Validates the Queue ID exists
- Retrieves the queue from memory
- Checks if the queue has elements
- Removes the first element from the queue
- Returns the element as output
- If queue is empty, returns an error immediately
This is a destructive operation - the element is removed from the queue and cannot be retrieved again.
Examples
Example 1: Simple Dequeue
Setup:
Queue contains: ["task1", "task2", "task3"]
Inputs:
- Queue ID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
Output:
- Element: "task1"
Queue after:
["task2", "task3"]
Example 2: Process Queue in Loop
Process all items from a queue until empty:
1. Create Queue with items → queueId
2. Get queue length → itemCount
3. Loop itemCount times:
- Dequeue (Queue ID: queueId) → element
- Process element
- Log element
4. Delete Queue
Example 3: Dequeue Objects
Queue contains:
[
{"id": 1, "url": "https://example.com/page1"},
{"id": 2, "url": "https://example.com/page2"}
]
Dequeue Output:
{"id": 1, "url": "https://example.com/page1"}
Usage:
1. Dequeue → pageData
2. Open Browser
3. Navigate to pageData.url
4. Process page
Example 4: Consumer Flow
Process items added by a producer:
1. Receive queueId from producer
2. While queue not empty:
- Try:
- Dequeue (Queue ID: queueId) → item
- Process item
- Catch (empty queue):
- Break loop
3. Delete Queue
Example 5: Conditional Processing
Dequeue and route based on element content:
1. Dequeue → task
2. If task.type == "email":
- Send email
3. Else if task.type == "sms":
- Send SMS
4. Else if task.type == "webhook":
- Call webhook
Use Cases
- Sequential processing - Process items one by one in order
- Task execution - Retrieve and execute tasks from a queue
- URL processing - Get next URL to scrape/visit
- Data transformation - Retrieve records for processing
- Batch operations - Process items collected in a queue
- Pipeline consumption - Consumer side of producer-consumer pattern
Error Handling
The node will return errors in the following cases:
- ErrInvalidArg - Queue ID is invalid or empty
- ErrNotFound - Queue with the specified ID does not exist
- Queue error: "queue with id ... is empty" - No elements available to dequeue
Common Errors and Solutions
Error: "queue with id ... is empty"
Cause: Attempting to dequeue from an empty queue.
Solution:
Option 1 - Use Wait node instead:
- Wait blocks until item is available
- More suitable for producer-consumer patterns
Option 2 - Check before dequeue:
- Track number of items enqueued
- Loop exact number of times
- Use counter to avoid over-dequeuing
Option 3 - Handle with try-catch:
- Try: Dequeue
- Catch: Exit loop when empty
Error: "queue with id ... does not exist"
Cause: The queue was deleted or never created.
Solution:
- Verify Queue ID is correct
- Ensure Create Queue was called successfully
- Check that queue wasn't deleted prematurely
- Verify Queue ID variable is in scope
Error: "queue with id ... is locked"
Cause: Queue is temporarily locked by concurrent operation.
Solution:
- Add small delay and retry
- Check for deadlocks in concurrent flows
- Ensure proper error handling in all flows
Tips and Best Practices
- Check queue state - Know how many items to dequeue or use try-catch
- Process immediately - Handle dequeued items right away to prevent data loss
- Error handling - Wrap in try-catch to gracefully handle empty queue
- Type awareness - Remember the data type of enqueued items
- Loop safely - Track iterations to avoid infinite loops on empty queue
- Store Queue ID - Keep Queue ID in a variable accessible to consumer flows
- Clean up - Delete queue after all items are processed
Performance Considerations
- Fast operation - Dequeue is a non-blocking, in-memory operation
- Immediate return - Returns error immediately if queue is empty
- Thread-safe - Multiple flows can dequeue concurrently (each gets unique item)
- FIFO guarantee - Always gets the oldest item in the queue
- No waiting - Use Wait node if you need blocking behavior
Dequeue vs Wait
| Feature | Dequeue | Wait |
|---|---|---|
| Blocking | No | Yes |
| Empty queue | Error | Waits for item |
| Timeout | None | Configurable |
| Use case | Known items | Producer-consumer |
Choose Dequeue when:
- You know items are available
- You want immediate error on empty queue
- Processing in a counted loop
Choose Wait when:
- Items arrive asynchronously
- You want to block until item available
- Implementing producer-consumer pattern
Processing Patterns
Pattern 1: Count and Process
1. Track items enqueued → count
2. Loop count times:
- Dequeue → item
- Process item
Pattern 2: Try Until Empty
1. Loop:
- Try:
- Dequeue → item
- Process item
- Catch (empty):
- Break
Pattern 3: Batch Processing
1. Dequeue N items into array
2. Process batch together
3. Repeat until queue empty
Pattern 4: Conditional Processing
1. Dequeue → item
2. If item meets criteria:
- Process
3. Else:
- Enqueue to different queue
Working with Different Element Types
String Elements
Dequeue → url
Navigate to url
Object Elements
Dequeue → customer
Send email to customer.email
Array Elements
Dequeue → recordSet
For each record in recordSet:
- Process record
Complex Objects
Dequeue → task
Execute task.action with task.parameters
Log task.result
Concurrent Dequeuing
Multiple flows can dequeue from the same queue:
Flow 1: Flow 2: Flow 3:
Dequeue → item1 Dequeue → item2 Dequeue → item3
Process item1 Process item2 Process item3
Each flow gets a unique item. FIFO order is maintained across all consumers.
Integration Example: Web Scraping Pipeline
Producer Flow:
1. Create Queue → urlQueueId
2. Get all product URLs
3. For each URL:
- Enqueue URL
Consumer Flows (3 parallel):
1. Receive urlQueueId
2. While items available:
- Try:
- Dequeue → url
- Open Browser
- Navigate to url
- Extract data
- Save to database
- Catch (empty):
- Exit loop
This pattern enables parallel processing of queued items.