Pipes Error Handler
Pipes offer a mechanism to specify an error policy to adopt in case an event produced by a source
or consumed by a sink
. Through the definition of an errorHandler
you will be able to apply certain logic to the failing event, such as simply logging, ignoring the event or posting the event to another Sink
.
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: my-binding
spec:
source: (1)
...
sink: (2)
...
errorHandler: (3)
1 | Reference to the source that provides data |
2 | Reference to the sink where data should be sent to |
3 | Error Handler Configuration |
Error Handler Types
We have different types of error handler: none
, log
and sink
. The errorHandler
parameter is optional.
No error handler
There may be certain cases where you want to just ignore any failure happening on your integration. In this situation just use a none
error handler.
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: my-binding
spec:
source:
...
sink:
...
errorHandler:
none: (1)
1 | none error handler does not expect any configuration |
Log error handler
Apache Camel offers a default behavior for handling any failure: log to standard output. However you can use the log
error handler to specify other behaviors such as redelivery or delay policy.
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: my-binding
spec:
source:
...
sink:
...
errorHandler:
log:
parameters: (1)
maximumRedeliveries: 3
redeliveryDelay: 2000
1 | Parameters belonging to the log error handler type |
Sink error handler
The Sink
is probably the most interesting error handler type as it allows you to redirect any failing event to any other component, such as a third party URI, a queue or even another Kamelet
which will be performing certain logic with the failing event.
apiVersion: camel.apache.org/v1
kind: Pipe
metadata:
name: my-binding
spec:
source:
...
sink:
...
errorHandler:
sink:
endpoint:
ref: (1)
kind: Kamelet
apiVersion: camel.apache.org/v1
name: error-handler
properties:
message: "ERROR!" (2)
...
parameters:
maximumRedeliveries: 1 (3)
...
1 | You can use ref or uri . ref will be interpreted by the operator according the kind , apiVersion and name . You can use any Kamelet , KafkaTopic channel or Knative destination. |
2 | Properties belonging to the endpoint (in this example, to the Kamelet named error handler) |
3 | Parameters belonging to the sink error handler type |