delay
delay
component: delay component. When the delay period of the message is reached, the message will be deleted from the pending queue and routed to the next node through the success link (Success
).
If the maximum pending message limit is reached, the messages will be routed through the failure link (Failure
). If overwrite is true, the message will be overwritten until the first message is processed, and then it will enter the delay queue again.
Used for timed tasks, scheduling, time-sensitive, delayed execution, peak shaving and other operations.
An example of a delay component
Suppose you have a temperature sensor that sends a telemetry data to RuleGo every second, containing the temperature value and timestamp. You want to trigger an alarm when the temperature exceeds 30 degrees, and clear the alarm when the temperature drops below 25 degrees. But you don't want to trigger and clear alarms frequently, so you set a 10-second delay time, that is, only trigger or clear alarms after the temperature stays above 30 degrees or below 25 degrees for 10 seconds.
At this time, you can configure the delay component: periodInSeconds=10
maxPendingMsgs=1
to achieve this function.
# Configuration
Field | Type | Description | Default |
---|---|---|---|
delayMs | string | Delay time in milliseconds; supports both numeric values and dynamic expressions, e.g. 1000 or ${metadata.delay} v0.34.0 | 60000 |
maxPendingMsgs | int | Maximum number of allowed pending messages deprecated Use delayMs instead | 1000 |
overwrite | bool | Whether to overwrite messages within the same cycle. true: only one message is kept per cycle; new messages will replace previous ones until the queue message is processed and the cycle re-enters the delay queue | false |
int | Delay time in seconds deprecated Use delayMs instead | 60 | |
int | Obtains delay time from metadata variables via ${metadataKey}; if present, this value takes precedence | none |
# Relation Type
- Success: After periodInSeconds time, send the message to the
Success
chain - Failure: The number of waiting messages > maxPendingMsgs, send the message to the
Failure
chain
# Execution result
None
# Configuration example
{
"id": "s1",
"type": "delay",
"name": "Execute delay component",
"configuration": {
"periodInSeconds": 1,
"maxPendingMsgs": 1
}
}
2
3
4
5
6
7
8
9
# Application example
Example reference: Example (opens new window)