Skip to content

Commit 675ccd4

Browse files
committed
feat: fallback actions
1 parent 4a86337 commit 675ccd4

File tree

1 file changed

+50
-2
lines changed

1 file changed

+50
-2
lines changed

en_US/data-integration/data-bridges.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ This process allows EMQX to extend beyond just message transmission between IoT
1313
- Currently, EMQX only supports the following external data systems to be served as Sources:
1414

1515
- MQTT Services
16-
- Kafka
16+
- Kafka
1717
- GCP PubSub
1818

1919
Among them, Kafka and GCP PubSub Sources are only supported in the EMQX Enterprise edition.
@@ -180,6 +180,54 @@ INSERT INTO msg(topic, qos, payload) VALUES(${topic}, ${qos}, ${payload});
180180

181181
In addition to automatically inferring field types, the prepared statement technology also prevents SQL injection to enhance security.
182182

183+
### Fallback Actions
184+
185+
Since EMQX 5.9.0, for a given Action, it's possible to define a set of Actions that will be triggered if processing of a message fails for whatever reason. Such set of Actions is called Fallback Actions. With Fallback Actions, it's possible to send data to secondary Sinks, reducing the probability of data loss, and may also serve to help observability of problems.
186+
187+
A few key facts about Fallback Actions:
188+
189+
- They are triggered whenever the primary Action fails or drops the message (due to buffer overflow or request TTL being reached).
190+
- They are always triggered in Async Query Mode, regardless of their configuration.
191+
- All configured Fallback Actions of a primary Action are triggered (i.e., we don't try one-by-one and stop at the first success).
192+
- Fallback Actions use the same buffering layer as all other actions, meaning that messages will be retried up to their request TTL or if there's buffer overflow.
193+
- Fallback Actions do **not** trigger further Fallback Actions: if a message being processed by a Fallback Action fails with an unrecoverable error or is dropped, no further Actions are triggered, even if there are other Fallback Actions configured.
194+
- Processing of messages by Fallback Actions do not affect metrics of their Primary Actions or of the original Rule that triggered the Primary Action.
195+
196+
#### Defining a Fallback Action
197+
198+
Let's say, for example, we want to configure some Fallback Actions for our HTTP Action called `my_http`. Let's also assume there exists an MQTT Action called `fallback` already configured.
199+
200+
In that case, we may simply define the following configuration:
201+
202+
```hcl
203+
actions {
204+
http {
205+
my_http {
206+
fallback_actions = [
207+
{kind = reference, type = mqtt, name = fallback},
208+
{
209+
kind = republish,
210+
args = {
211+
topic = "fallback/republish/topic"
212+
qos = 1
213+
payload = "${payload}"
214+
}
215+
}
216+
]
217+
}
218+
}
219+
mqtt {
220+
fallback {
221+
fallback_actions = [
222+
{kind = reference, type = mqtt, name = another_fallback}
223+
]
224+
}
225+
}
226+
}
227+
```
228+
229+
In the example above, if a message fails to be processed by `my_http`, then we will forward the same message to the `fallback` MQTT Action, and also republish the original message according to the parameters above. If the message then fails to be processed by `fallback`, even though there is a Fallback Action `another_fallback` configured for `fallback`, the message will **not** be further forwarded to `another_fallback`. If `fallback` were to receive a message itself as a Primary Action, then `another_fallback` could be triggered on processing failures.
230+
183231
## Sink Status and Statistics
184232

185233
You can view the running status and statistics of a Sink on the Dashboard to know if the Sink is operating properly.
@@ -220,7 +268,7 @@ The `success` statistic counts the number of messages that were successfully rec
220268

221269
The `failed` statistic counts the number of messages that failed to be received by the external data system. `retried.failed` is a sub-count of `failed` which tracks the number of messages with delivery retried at least once. Therefore, `retried.failed <= failed`.
222270

223-
#### Dropped
271+
#### Dropped
224272

225273
The `dropped` statistic counts the number of messages that were dropped without any delivery attempt. It contains several more specific categories, each indicating a distinct reason for the drop. The calculation for `dropped` is:`dropped = dropped.expired + dropped.queue_full + dropped.resource_stopped + dropped.resource_not_found`.
226274

0 commit comments

Comments
 (0)