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 value |
---|---|---|---|
periodInSeconds | int | Delay time, in seconds | 60 |
maxPendingMsgs | int | The maximum number of messages allowed to be pending | 1000 |
periodInSecondsPattern | int | Get the delay time from the metadata variable by ${metadataKey}, if there is a value, take this value first. | None |
overwrite | bool | Whether to overwrite the messages in the period. true: Only one message is kept in the period, and the new message will overwrite the previous message. Until the message in the queue is processed, it will enter the delay queue again. | false |
# 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)