There is one example in the camel-kamelets-example repo: https://github.com/apache/camel-kamelets-examples/tree/main/jbang/error-handler
Il ven 2 giu 2023, 10:03 Pasquale Congiusti <pasquale.congiu...@gmail.com> ha scritto: > Hello, > Error handler should be managed differently in Kamelets. Basically the > problem is that a Kamelet is a RouteTemplate, so it is like a new Route and > won't "inherit" the configuration you've defined in the original route. I > think you need to define your error inside the Kamelet specification (which > it's not a very nice design). In Camel K, we've created a layer on top of > it inside the runtime, in order to let the user define the error handling > in the Binding [1]. > > We had some draft work [2] to enhance that, expecting a similar global > mechanism in Camel. However, I haven't followed by near the recent > developments in Camel 4 to tell you if this is going to be included in the > new version or not. > > Regards, > Pasquale. > > [1] > > https://camel.apache.org/camel-k/1.12.x/kamelets/kameletbindings-error-handler.html > [2] https://github.com/apache/camel-k-runtime/pull/868 > > On Fri, Jun 2, 2023 at 7:35 AM Mikael Koskinen <mijap...@gmail.com> wrote: > > > Hey, > > > > I wonder if anyone has any info regarding this issue? It's possible > > (and maybe quite likely!) that I'm using the > > routeConfiguration/errorHandler incorrectly. > > > > Thanks in advance. > > > > Best regards, > > Mikael > > > > pe 19. toukok. 2023 klo 15.24 Mikael Koskinen (mijap...@gmail.com) > > kirjoitti: > > > > > > Hi, > > > > > > I'm encountering a problem where route configuration's error handler > > > isn't run if the exception happens on a Kamelet. Here's the gist with > > > tries to show the issue: > > > > > > https://gist.githubusercontent.com/mikoskinen/4e3e3a8efdf891890a2a46dfddae1d48/raw/09055bcdc1c2252a77a069fcebd07d6f727db555/camel-yaml-kamelet-errorhandling.yaml > > > > > > More details: > > > > > > > > > First, here's a (working) version with no Kamelets: > > > > > > - routeConfiguration: > > > errorHandler: > > > deadLetterChannel: > > > deadLetterUri: direct:errorHandler > > > redeliveryPolicy: > > > maximumRedeliveries: 0 > > > - route: > > > from: > > > uri: timer:timer > > > steps: > > > - setBody: > > > expression: > > > constant: > > > expression: Hello World > > > - marshal: > > > json: > > > library: jackson > > > prettyPrint: true > > > - to: > > > uri: > > https://webhook.sitessss/b7562774-4939-4e90-9337-5b9dd4d2ff1d > > > - route: > > > from: > > > uri: direct:errorHandler > > > steps: > > > - log: > > > message: Handling error > > > loggingLevel: WARN > > > description: Handle Error > > > > > > When run, this is what I see in the logs: > > > > > > 2023-05-19 15:14:13.783 WARN 20268 --- [- timer://timer] > > > testing.camel.yaml:25 : Handling error > > > 2023-05-19 15:14:14.626 WARN 20268 --- [- timer://timer] > > > testing.camel.yaml:25 : Handling error > > > > > > It is working as I expected. > > > > > > Now, with a just one change where HTTP component is changed to Kamelet > > > HTTP Sink and I'm getting completely different result. > > > > > > - routeConfiguration: > > > errorHandler: > > > deadLetterChannel: > > > deadLetterUri: direct:errorHandler > > > redeliveryPolicy: > > > maximumRedeliveries: 0 > > > - route: > > > from: > > > uri: timer:timer > > > steps: > > > - setBody: > > > expression: > > > constant: > > > expression: Hello World > > > - marshal: > > > json: > > > library: jackson > > > prettyPrint: true > > > - to: > > > uri: kamelet:http-sink > > > parameters: > > > url: > > https://webhook.sitessss/b7562774-4939-4e90-9337-5b9dd4d2ff1d > > > - route: > > > from: > > > uri: direct:errorHandler > > > steps: > > > - log: > > > message: Handling error > > > loggingLevel: WARN > > > description: Handle Error > > > > > > Now when run I'm getting the stacktrace and there's no "Handling > > > error" to be found: > > > > > > 2023-05-19 15:20:22.084 INFO 17192 --- [ main] > > > el.impl.engine.AbstractCamelContext : Apache Camel 3.20.4 (tes > > > ting) started in 4s854ms (build:196ms init:3s906ms start:752ms > > JVM-uptime:8s) > > > 2023-05-19 15:20:23.165 ERROR 17192 --- [- timer://timer] > > > or.errorhandler.DefaultErrorHandler : Failed delivery for (Mes > > > sageId: B24BA7702CBB985-0000000000000000 on ExchangeId: > > > B24BA7702CBB985-0000000000000000). Exhausted after delivery atte > > > mpt: 1 caught: java.net.UnknownHostException: No such host is known > > > (webhook.sitessss) > > > > > > Message History > > > > > > ------------------------------------------------------------------------------------------------------------------------ > > > --------------- > > > Source ID Processor > > > Elapsed (ms) > > > testing.camel.yaml:9 route1/route1 from[timer://timer] > > > 2701025406 > > > testing.camel.yaml:11 route1/setBody1 setBody[constant{Hello World}] > > > 2 > > > testing.camel.yaml:15 route1/marshal1 > > > marshal[org.apache.camel.model.dataformat.JsonDa > > > > > > A bug or do I have to configure something more to get the kamelet to > > > use the route's error handler? > > > > > > Best regards, > > > Mikael > > >