Camel rest route w Spring ControllerAdvice?

2021-03-02 Thread Stephen Bassett
I have a Spring app. I created an ExceptionHandler class and annotated it
with @ControllerAdvice. Exceptions thrown from my app are handled there.
However, an exception thrown from within a Camel route that is a
@RestController and has a restI() route will not be handled in my
ExceptionHandler class.

Has anyone else done this? It would be nice if I could put all of my
handling in one place in the ControllerAdvice.  I am not sure why the Camel
rest route is not handled.

Thanks,

Steve Bassett

@RestControllerAdvice
public class ExceptionTranslator {
@ExceptionHandler(Exception.class)
public ResponseEntity handleThrowable(Exception exception) {
final String description = "general exception handler";
HttpStatus statusCode = HttpStatus.INTERNAL_SERVER_ERROR;
final String jsonBody = getJsonResponse(description, statusCode,
exception);
return new ResponseEntity<>(jsonBody, statusCode);
}

@ExceptionHandler(MyInternalException.class)
public ResponseEntity handleMyInternalException(MyInternalException
exception) {
...
more exception handlers
}

@RestController
public class MyRestRoute extends RouteBuilder {
@Override
public void configure() throws Exception {
rest()
.get("/hello/route")
.produces("text/plain")
.to("direct:hello-sub-route");

from("direct:hello-sub-route")
.process(exchange -> {
throw new IOException(" IOException -");
})
.transform().simple(" hello sub-route -")
.to("log:my-log");
}
}


Prometheus metrics for success/failure

2020-07-01 Thread Stephen Bassett
I would like to monitor Camel routes and track down issues on routes that
are failing or throwing exceptions.

For folks out there using Camel+Micrometer+Prometheus to gather metrics:
can you get metrics related to success/failure rates of Camel routes in
Prometheus? Can you use the metrics to identify problematic routes?

Follow up question: has anyone tried getting Camel metrics via JMX? How
does that compare with Prometheus?

Thanks

Steve