Skip to main content

try

DEPRECATED

This component is deprecated and will be removed in the next major version release. Please consider moving onto alternative components.

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.

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

Alternatives

This output has been renamed to the (hopefully more appropriate) fallback output.

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:
try:
- 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 try sequence uses batching, like so:

output:
try:
- 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 try 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 guarantees.