This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch kamelet2 in repository https://gitbox.apache.org/repos/asf/camel.git
commit a66d1aa91907531ef865acf3be03a9cd4ad3cc88 Author: Claus Ibsen <[email protected]> AuthorDate: Mon Jan 27 11:03:47 2025 +0100 CAMEL-21599: camel-kamelet - Rework error handler for kamelets to be more standard Camel. WIP --- .../src/main/docs/kamelet-component.adoc | 52 ++++++++++++++++++++-- .../ROOT/pages/camel-4x-upgrade-guide-4_10.adoc | 4 +- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/components/camel-kamelet/src/main/docs/kamelet-component.adoc b/components/camel-kamelet/src/main/docs/kamelet-component.adoc index acff0f237f0..f00bde4d287 100644 --- a/components/camel-kamelet/src/main/docs/kamelet-component.adoc +++ b/components/camel-kamelet/src/main/docs/kamelet-component.adoc @@ -48,8 +48,56 @@ The *kamelet* endpoint is *lenient*, which means that the endpoint accepts addit If a xref:manual::route-template.adoc[Route Template] is not found, the *kamelet* endpoint tries to load the related *kamelet* definition from the file system (by default `classpath:kamelets`). The default resolution mechanism expects _Kamelets_ files to have the extension `.kamelet.yaml`. -== Examples +=== Error Handling + +The error handling when using kamelets are using the same error handling +that are from the route where the kamelets are being used. + +Suppose you have kamelets that would cause an exception during processing, such +as the source below. Now because the route has been configured with a _dead letter channel_ +as the error handler, then the exception from the kamelet will be handled by the route error handler. +Which means you will se a WARN being logged. + +[source,yaml] +---- +- route: + errorHandler: + deadLetterChannel: + deadLetterUri: log:dead?level=WARN + id: myRoute + from: + uri: "kamelet:my-error-source/source" + steps: + - log: "${body}" +---- +For sink kamelets then error handling also allows to perform retries. + +So suppose you have the following route: + +[source,yaml] +---- +- route: + errorHandler: + deadLetterChannel: + deadLetterUri: log:dead?level=WARN + redeliveryPolicy: + maximumRedeliveries: 5 + redeliveryDelay: "5000" + id: myRoute + from: + uri: "direct:start" + steps: + - to: + uri: "kamelet:my-error-sink/sink" + - log: "${body}" +---- + +Then notice the error handler has been configured to do redeliveries up till 5 times with 5 sec delay between. +Suppose the sink kamelet is throwing an exception, then Camel will now perform the redelivery attempt +at the point of origin, which means inside the Kamelet. + +== Examples _Kamelets_ can be used as if they were standard Camel components. For example, suppose that we have created a Route Template as follows: @@ -100,6 +148,4 @@ from("direct:template") ---- - - include::spring-boot:partial$starter.adoc[] diff --git a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc index 19dfa053d64..46297001060 100644 --- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc +++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_10.adoc @@ -120,7 +120,7 @@ Now the kamelets are _first class_ and gives users the full power to handle erro This change has most an effect on source Kamelets. For sink or action Kamelets, then any error would be propagated back to the route, that could still handle the error. -However, if the erro handler is configured to perform retries, then the retry would be +However, if the error handler is configured to perform retries, then the retry would be starting all over again calling the sink Kamelet. This change will let the error handler perform retries at the original of the error (also inside the Kamelet), the same as regular Camel routes. @@ -146,7 +146,7 @@ So suppose you have the following route: ---- Then notice the error handler has been configured to do redeliveries up till 5 times with 5 sec delay between. -Suppose the sink kamelet is throwing an exception, then Camel will now perform the redeliver attempt +Suppose the sink kamelet is throwing an exception, then Camel will now perform the redelivery attempt at the point of origin, which means inside the Kamelet. Previously the redelivery will only happen at the route level, calling the kamelet all over again.
