drop_on
Attempts to write messages to a child output and if the write fails for one of a list of configurable reasons the message is dropped instead of being reattempted.
# Config fields, showing default valuesoutput:label: ""drop_on:error: falseback_pressure: ""output: {}
Regular Benthos outputs will apply back pressure when downstream services aren't accessible, and Benthos retries (or nacks) all messages that fail to be delivered. However, in some circumstances, or for certain output types, we instead might want to relax these mechanisms, which is when this output becomes useful.
Fields​
error
​
Whether messages should be dropped when the child output returns an error. For example, this could be when an http_client output gets a 4XX response code.
Type: bool
Default: false
back_pressure
​
An optional duration string that determines the maximum length of time to wait for a given message to be accepted by the child output before the message should be dropped instead. The most common reason for an output to block is when waiting for a lost connection to be re-established. Once a message has been dropped due to back pressure all subsequent messages are dropped immediately until the output is ready to process them again. Note that if error
is set to false
and this field is specified then messages dropped due to back pressure will return an error response.
Type: string
Default: ""
# Examplesback_pressure: 30sback_pressure: 1m
output
​
A child output.
Type: output
Default: {}
Examples​
- Dropping failed HTTP requests
- Dropping from outputs that cannot connect
In this example we have a fan_out broker, where we guarantee delivery to our Kafka output, but drop messages if they fail our secondary HTTP client output.
output:broker:pattern: fan_outoutputs:- kafka:addresses: [ foobar:6379 ]topic: foo- drop_on:error: trueoutput:http_client:url: http://example.com/foo/messagesverb: POST
Most outputs that attempt to establish and long-lived connection will apply back-pressure when the connection is lost. The following example has a websocket output where if it takes longer than 10 seconds to establish a connection, or recover a lost one, pending messages are dropped.
output:drop_on:back_pressure: 10soutput:websocket:url: ws://example.com/foo/messages