Error Handling in Kamelet Binding — By Example

Sadhana Nandakumar
3 min readFeb 22, 2022

In an earlier article, we had discussed, how Kamelet allows users to connect to external systems via a simplified interface, hiding all the low-level details about how those connections are implemented. We had also explored, how by enabling the Jolokia trait on the Kamelet binding, we can register the integration with the fuse console for monitoring.

In this article, we will explore the error handling options available for the Kamelet binding.

Let us assume we have a simple integration, that reads from an AMQ broker queue, and invokes a REST endpoint.

For this, we will set up the AMQ Broker, Camel-K, and the Fuse Console on openshift, check out the post to learn more about how to install these operators on openshift.

The integration would look like this.

We have used the AMQ Source and HTTP Sink Kamelet definitions to define this integration. Notice how we are using a dummy URL in the sink section to simulate the error condition.

There are different types of error handlers including none, log, and sink. There may be situations where we might just need to ignore the failure, for such cases we can use the None error handler.

Apache camel provides a default behavior of log to standard output for error handling. We can however specify redelivery or delay policy using the log error handler.

Let us add a simple error handler to set up a retry and delay as defined here.

We will now deploy the YAML definition.

Let us send a message to the queue “sourcequeue”.

We can now see that since the HTTP sink URL is unreachable, the error is logged on the standard out. We can see from the log message that, retry attempts were performed as defined in the error handler definition on the kamelet binding.

Let's say we need more sophisticated error handling, where we would like to redirect the failed messages to a different component. This is when a sink handler comes in handy.

In our example, we will redirect the messages on error to another AMQ topic called “errorqueue”

Let us now modify the integration to add the error handler sink definition.

Let us apply this YAML definition, and add a message to the “sourcequeue”.

You should now see the message being pushed to the “errorqueue” on error.

The Fuse Console also shows the error handler definition.

References:

https://camel.apache.org/camel-k/1.8.x/kamelets/kameletbindings-error-handler.html#kameletbindings-error-handler-types

--

--

Sadhana Nandakumar

Sadhana is a Sr Technical Product Marketing Manager specializing in Salesforce Platform