Message Stack

Store and retrieve messages from a stack/queue with optional delay processing

Overview

This node manages a message stack (or queue) allowing users to store, retrieve, and manipulate messages with various operations such as pushing, popping, peeking, flushing, and clearing messages. It supports multiple independent stacks identified by a stack name. The node is useful for scenarios where message accumulation, delayed processing, or batch handling of messages is needed, such as buffering data before processing or managing task queues.

Use Case Examples

  1. Push messages to a named stack to accumulate data for batch processing.
  2. Pop a specified number of messages from the stack for processing.
  3. Peek at messages without removing them to inspect the current queue state.
  4. Flush all messages to retrieve and clear the stack at once, useful for batch operations or cleanup.

Properties

Name Meaning
Stack Name The name of the stack to operate on, allowing multiple independent stacks to be managed separately.

Output

JSON

  • success - Indicates if the operation was successful
  • operation - The operation performed on the stack
  • stackName - The name of the stack involved in the operation
  • messagesPushed - Number of messages added to the stack (for push operations)
  • totalMessages - Total number of messages currently in the stack
  • delaySeconds - Delay time in seconds used for delayed push operations
  • autoFlush - Indicates if auto flush is enabled after delay
  • willFlushAt - Timestamp when the stack will auto flush
  • messagesReturned - Number of messages returned from the stack
  • messagesPopped - Number of messages removed from the stack
  • messagesPeeked - Number of messages viewed without removal
  • messagesFlushed - Number of messages flushed from the stack
  • size - Current number of messages in the stack
  • lastActivity - Timestamp of the last activity on the stack
  • hasPendingTimeout - Indicates if there is a pending timeout for delayed processing
  • messagesCleared - Number of messages cleared from the stack
  • messages - Array of messages returned in batch operations
  • count - Count of messages returned in batch operations
  • message - Informational message about the stack state, e.g., empty stack

Troubleshooting

  • Ensure the stack name is provided and consistent to avoid operating on unintended stacks.
  • If using delayed push operations, verify that the delay and auto flush settings are correctly configured to prevent messages from being stuck in the stack.
  • When popping or peeking messages, check the maxMessages parameter to avoid unexpected empty results.
  • If the node throws an error about unsupported operations, verify that the operation parameter is set to one of the supported values: push, pop, peek, flush, size, clear, pushWithDelay, or pushWaitFlush.

Discussion