Skip to main content

fallback

Attempts to send each message to a child output, starting from the first output on the list. If an output attempt fails then the next output in the list is attempted, and so on.

Introduced in version 3.58.0.

# Config fields, showing default values
output:
label: ""
fallback: []

This pattern is useful for triggering events in the case where certain output targets have broken. For example, if you had an output type http_client but wished to reroute messages whenever the endpoint becomes unreachable you could use this pattern:

output:
fallback:
- http_client:
url: http://foo:4195/post/might/become/unreachable
retries: 3
retry_period: 1s
- http_client:
url: http://bar:4196/somewhere/else
retries: 3
retry_period: 1s
processors:
- text:
operator: prepend
value: 'failed to send this message to foo: '
- file:
path: /usr/local/benthos/everything_failed.jsonl

Batching#

When an output within a fallback sequence uses batching, like so:

output:
fallback:
- dynamodb:
table: foo
string_columns:
id: ${!json("id")}
content: ${!content()}
batching:
count: 10
period: 1s
- file:
path: /usr/local/benthos/failed_stuff.jsonl

Benthos makes a best attempt at inferring which specific messages of the batch failed, and only propagates those individual messages to the next fallback tier.

However, depending on the output and the error returned it is sometimes not possible to determine the individual messages that failed, in which case the whole batch is passed to the next tier in order to preserve at-least-once delivery guarantees.