Skip to main content

Enqueue

Adds an element to the end of an in-memory queue. Elements are added in FIFO (First-In-First-Out) order and will be retrieved in the same order using Dequeue.

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.
info

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.
  • Element - The data element to add to the queue. Can be any type: string, number, object, array, boolean, etc.

How It Works

The Enqueue node adds an element to the end of the specified queue. When executed, the node:

  1. Validates the Queue ID exists
  2. Retrieves the queue from memory
  3. Adds the element to the end of the queue
  4. Returns control immediately (non-blocking operation)

Elements are stored in the order they are enqueued and will be dequeued in the same order (FIFO).

Examples

Example 1: Enqueue Simple Strings

Inputs:

Result: URL string added to queue.

Example 2: Enqueue Objects

Inputs:

  • Queue ID: "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
  • Element:
{
"customerName": "John Doe",
"email": "john@example.com",
"orderId": "ORD-12345",
"amount": 299.99
}

Result: Customer order object added to queue for processing.

Example 3: Enqueue in a Loop

Process items from a data source and add them to a queue:

1. Create Queue → queueId
2. Loop through Excel rows
- For each row:
- Enqueue (Queue ID: queueId, Element: row)
3. Return queueId for consumer to process

Example 4: Producer Flow

Collect URLs from a webpage and add them to a queue:

1. Create Queue → urlQueueId
2. Open Browser
3. Navigate to listing page
4. Get all product links → links
5. For each link in links:
- Enqueue (Queue ID: urlQueueId, Element: link)
6. Pass urlQueueId to consumer flow

Example 5: Conditional Enqueuing

Add items to queue based on conditions:

1. Create Queue → taskQueueId
2. Read CSV file → data
3. For each row in data:
- If row.status == "pending":
- Enqueue (Queue ID: taskQueueId, Element: row)
4. Process only pending items

Use Cases

  • Web scraping - Collect URLs to visit in a FIFO queue
  • Data processing - Add records from database/files for sequential processing
  • Task scheduling - Build a list of tasks to execute in order
  • Batch operations - Collect items before processing them
  • Pipeline feeding - Add items that multiple consumers can process
  • Event buffering - Queue incoming events for ordered processing

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
  • ErrInternal - Queue operation failed (e.g., queue is locked or full)

Common Errors and Solutions

Error: "queue with id ... does not exist"

Cause: The Queue ID is invalid or the queue was already deleted.

Solution:

  • Verify you're using the correct Queue ID from Create Queue
  • Ensure the queue wasn't deleted before this operation
  • Check that the Queue ID variable is properly set

Error: "queue with id ... is locked"

Cause: The queue is temporarily locked by another operation.

Solution:

  • This is usually temporary; the operation should retry
  • If persistent, check for deadlocks in concurrent flows
  • Ensure proper queue cleanup in error handlers

Error: "queue with id ... is full"

Cause: The queue has reached its capacity limit.

Solution:

  • Process (dequeue) items to free space
  • Consider batching operations differently
  • Split work across multiple queues

Tips and Best Practices

  • Validate before enqueuing - Check that data is in the expected format before adding to queue
  • Use meaningful elements - Store complete objects with all necessary data for processing
  • Handle duplicates - Implement logic to prevent duplicate entries if needed
  • Monitor queue size - Track how many items you're adding for performance planning
  • Batch enqueuing - Use loops to efficiently add multiple items
  • Error handling - Wrap Enqueue in try-catch to handle queue errors gracefully
  • Type consistency - Keep element types consistent within a queue for easier processing

Performance Considerations

  • Fast operation - Enqueue is a non-blocking, in-memory operation
  • No size limits - Queue can grow until memory is exhausted
  • Thread-safe - Multiple flows can enqueue concurrently
  • FIFO guarantee - Order is preserved even with concurrent enqueueing
  • Memory usage - Large objects consume more memory; consider serializing if needed

Concurrent Access

Memory Queue supports concurrent enqueuing:

Flow 1:                    Flow 2:
Create Queue → queueId (receives queueId)
Enqueue item1 Enqueue item4
Enqueue item2 Enqueue item5
Enqueue item3 Enqueue item6

All items will be added in order of execution, maintaining FIFO within each flow.

Integration Patterns

Pattern 1: Single Producer, Single Consumer

Producer Flow:
1. Create Queue
2. Loop: Enqueue items
3. Signal consumer

Consumer Flow:
1. Receive queue ID
2. Loop: Dequeue and process
3. Delete queue

Pattern 2: Multiple Producers, Single Consumer

Producer Flow 1:
- Enqueue items to shared queue

Producer Flow 2:
- Enqueue items to same queue

Consumer Flow:
- Dequeue all items in FIFO order

Pattern 3: Batch Collection

1. Create Queue
2. Collect items over time via Enqueue
3. When threshold reached:
- Process all items
- Clear queue for next batch

Working with Different Data Types

Strings

"https://example.com/product/123"

Numbers

42

Booleans

true

Arrays

["item1", "item2", "item3"]

Objects

{
"name": "Widget",
"sku": "WID-001",
"quantity": 100,
"metadata": {
"warehouse": "A",
"location": "R5-S3"
}
}

All data types are supported as elements. The dequeued value will maintain its original type.