Delete Queue
Permanently deletes an in-memory queue and releases its memory. The queue and all its elements are removed, and the Queue ID becomes invalid.
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.
How It Works
The Delete Queue node permanently removes a queue from memory. When executed, the node:
- Validates the Queue ID exists
- Retrieves the queue from memory
- Removes all elements from the queue
- Deletes the queue structure
- Frees all associated memory
- Invalidates the Queue ID (cannot be used again)
After deletion, any attempt to use the Queue ID will result in an error.
Examples
Example 1: Clean Shutdown
Complete a workflow and clean up resources:
1. Create Queue → queueId
2. Enqueue items
3. Process all items
4. Delete Queue (Queue ID: queueId)
Result: Queue and all resources are freed from memory.
Example 2: After Batch Processing
Delete queue when all batches are processed:
1. Create Queue → batchQueueId
2. For each batch:
- Enqueue batch items
- Process items
- Clear Queue
3. Delete Queue (Queue ID: batchQueueId)
Example 3: Error Cleanup
Ensure cleanup even when errors occur:
1. Create Queue → queueId
2. Try:
- Enqueue items
- Process items
3. Catch:
- Log error
4. Finally:
- Delete Queue (Queue ID: queueId)
Example 4: Temporary Queue Pattern
Create, use, and delete queue in single flow:
1. Create Queue → tempQueueId
2. Enqueue data items
3. While queue not empty:
- Dequeue → item
- Process item
4. Delete Queue (Queue ID: tempQueueId)
Example 5: Multiple Queues Cleanup
Delete multiple queues at end of automation:
1. Create Queue → queue1Id
2. Create Queue → queue2Id
3. Create Queue → queue3Id
4. ... process with all queues ...
5. Delete Queue (queue1Id)
6. Delete Queue (queue2Id)
7. Delete Queue (queue3Id)
Use Cases
- Resource cleanup - Free memory when queue is no longer needed
- Workflow completion - Clean up at end of automation
- Error recovery - Remove failed queues and start fresh
- Temporary processing - Create-use-delete pattern for one-time tasks
- Memory management - Prevent memory leaks in long-running automations
- Session end - Clean up all queues when automation completes
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 (already deleted)
Common Errors and Solutions
Error: "queue with id ... does not exist"
Cause: Queue was already deleted or never created.
Solution:
- Check if queue was already deleted
- Verify Queue ID is correct
- Use Continue On Error if you want to ignore already-deleted queues
- Track deletion state to prevent double-deletion
Attempting to Use Deleted Queue
Scenario:
1. Delete Queue (queueId)
2. Enqueue (queueId) → ERROR: queue does not exist
Solution:
- Always delete queue as the last operation
- Don't reuse Queue ID after deletion
- Create new queue if more work is needed
Tips and Best Practices
- Always delete - Delete queues when finished to prevent memory leaks
- Delete last - Make deletion the final operation on a queue
- Use Finally blocks - Ensure deletion happens even on errors
- One delete per queue - Don't attempt to delete the same queue twice
- Track queue lifecycle - Know when to create vs when to delete
- Clean up on exit - Delete all queues before automation ends
- Avoid premature deletion - Ensure all consumers are done before deleting
Performance Considerations
- Immediate cleanup - Memory is freed immediately
- Fast operation - Deletion is a quick in-memory operation
- No recovery - Once deleted, queue cannot be restored
- Complete cleanup - All elements and queue structure are removed
- Thread-safe - Safe to delete from any flow
Delete vs Clear
| Operation | Queue After | Memory | Queue ID | Use Case |
|---|---|---|---|---|
| Delete | Removed | Freed completely | Invalid | Done with queue |
| Clear | Exists | Elements freed | Valid | Reuse queue |
Use Delete when:
- Completely finished with the queue
- Want to free all memory
- Queue won't be used again
- Workflow is ending
Use Clear when:
- Want to keep queue but remove elements
- Planning to reuse queue
- Processing in batches
- Need same Queue ID
Queue Lifecycle
A complete queue lifecycle looks like:
1. Create Queue → Get Queue ID
2. Enqueue elements → Add data
3. Process elements → Dequeue or Wait
4. Clear (optional) → Remove all elements
5. Enqueue more (optional) → Add new data
6. Process more (optional) → Dequeue or Wait
7. Delete Queue → Free memory
Processing Patterns
Pattern 1: Simple Create-Use-Delete
1. Create Queue → queueId
2. Enqueue items
3. Process items
4. Delete Queue
Pattern 2: Try-Finally Cleanup
1. Create Queue → queueId
2. Try:
- Enqueue and process
3. Catch:
- Handle errors
4. Finally:
- Delete Queue (queueId)
Pattern 3: Multiple Queue Cleanup
1. queues = []
2. For each task_type:
- Create Queue → queueId
- Add queueId to queues array
3. Process all queues
4. For each queueId in queues:
- Delete Queue (queueId)
Pattern 4: Conditional Deletion
1. Create Queue → queueId
2. Process items
3. If workflow_complete:
- Delete Queue
4. Else:
- Keep queue for next run
Memory Leak Prevention
Memory queues can cause memory leaks if not deleted. Always ensure cleanup:
Bad Practice:
Flow A:
1. Create Queue → queueId
2. Process items
3. (Queue never deleted - MEMORY LEAK)
Good Practice:
Flow A:
1. Create Queue → queueId
2. Try:
- Process items
3. Finally:
- Delete Queue (queueId)
Best Practice:
Main Flow:
1. activeQueues = []
2. Try:
- Call subflows
- Add each queue to activeQueues
3. Finally:
- For each queueId in activeQueues:
- Try: Delete Queue (queueId)
- Catch: Log "Already deleted"
Concurrent Access Cleanup
When multiple flows access a queue, coordinate deletion:
Producer Flow:
1. Create Queue → queueId
2. Share queueId with consumers
3. Enqueue all items
4. Signal "done enqueueing"
5. Wait for consumers to finish
Consumer Flows:
1. Receive queueId
2. Process items
3. Signal "done processing"
Coordinator:
1. Wait for all consumers done
2. Delete Queue (queueId)
Integration Examples
Example: Web Scraping Cleanup
1. Create Queue → urlQueueId
2. Scrape listing page for URLs
3. Enqueue all URLs
4. For each URL in queue:
- Dequeue → url
- Visit and extract data
- Save to database
5. Delete Queue (urlQueueId)
6. Log "Scraping complete, resources cleaned up"
Example: Batch Email Processing
1. Create Queue → emailQueueId
2. Try:
- Read CSV with email addresses
- For each row:
- Enqueue email data
- Process queue and send emails
3. Catch:
- Log error
4. Finally:
- Delete Queue (emailQueueId)
- Log "Email queue cleaned up"
Example: Multi-Stage Pipeline
1. Create Queue → stage1Queue
2. Create Queue → stage2Queue
3. Try:
- Stage 1: Process items, output to stage1Queue
- Stage 2: Read stage1Queue, output to stage2Queue
- Stage 3: Read stage2Queue, final processing
4. Finally:
- Delete Queue (stage1Queue)
- Delete Queue (stage2Queue)
When to Delete
Immediately delete when:
- Workflow is complete
- Queue was created for temporary use
- No more items will be added or processed
- You want to free memory
Delay deletion when:
- Multiple flows still accessing queue
- Items might be added later
- Implementing a pause/resume pattern
- Queue might be needed for retry logic
Best Practices Summary
- Always delete queues when done
- Use try-finally to ensure cleanup
- Delete queues in reverse order of creation
- Track active queues for bulk cleanup
- Don't attempt to use queue after deletion
- Coordinate deletion in concurrent scenarios
- Log deletion for debugging
- Monitor memory usage in long-running automations