Message Stack

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

Overview

This node manages a message stack (queue) with various operations including pushing messages with an optional delay before processing. The 'Push with Delay' operation allows messages to be added to a named stack and waits for a specified delay period to accumulate more messages before optionally flushing them. This is useful in scenarios where batch processing of messages is desired after collecting them over a time window, such as aggregating events or buffering data before sending it downstream.

Use Case Examples

  1. Use 'Push with Delay' to collect sensor data messages over 10 seconds before processing them in bulk.
  2. Accumulate user activity logs in a stack and flush them after a delay to reduce processing frequency.

Properties

Name Meaning
Stack Name The name of the stack to operate on, allowing multiple independent stacks.
Delay (Seconds) Time to wait for accumulating messages before processing (applicable for pushWithDelay and pushWaitFlush operations).
Auto Flush on Delay Whether to automatically flush messages after the delay period (applicable for pushWithDelay and pushWaitFlush operations).

Output

JSON

  • success - Indicates if the operation was successful.
  • operation - The operation performed, e.g., pushWithDelay.
  • stackName - The name of the stack on which the operation was performed.
  • messagesPushed - Number of messages pushed to the stack in this operation.
  • totalMessages - Total number of messages currently in the stack.
  • delaySeconds - Configured delay time in seconds before processing messages.
  • autoFlush - Indicates if auto flush is enabled after the delay.
  • willFlushAt - Timestamp when the stack will be flushed if auto flush is enabled.

Troubleshooting

  • If the stack name is not unique or consistent, messages may be mixed between different logical stacks. Use distinct stack names to avoid this.
  • If auto flush is enabled but no messages appear to be processed after the delay, ensure the node execution environment allows asynchronous timeouts to complete.
  • If the delay is set too low, messages may be flushed too frequently, reducing the benefit of batching.

Discussion