Hi,
I am trying to enable hystrix in our camel application and I am trying to
understand how the exceptions are dealt when using the Hystrix EIP .
When we set the timeOut to a smaller value than the endpoint call, there is
no exception thrown that we can deal with. I need a handle to this
exception so that I can clean up some data and fail the transaction
gracefully. The process stops abruptly. What am I missing here? Is there a
different way to handle this?
from("direct:hystrixSlowEndpoint")
.hystrix()
.hystrixConfiguration().executionTimeoutInMilliseconds(2000).groupKey("my-key").end()
.log("Before call to endpoint")
.to("direct:slow")
.log("After call to endpoint")
.end()
.log("After Hystrix ${body}");
from("direct:slow")
.log("Slow processing start: ${threadName}")
.delay(3000)
.transform().constant("Slow response")
.log("Slow processing end: ${threadName}");
Log excerpt -
2017-03-20 16:47:48,927 [ystrix-my-key-1] INFO
rixRouteBuilderTest$mySlowTest - Before Log[Hystrix processing start:
${threadName}] with body null
2017-03-20 16:47:48,927 [ystrix-my-key-1] INFO route4
- Hystrix processing start: hystrix-my-key-1
2017-03-20 16:47:48,929 [ystrix-my-key-1] INFO
rixRouteBuilderTest$mySlowTest - Before To[direct:slow] with body null
2017-03-20 16:47:48,930 [ystrix-my-key-1] INFO
rixRouteBuilderTest$mySlowTest - Before Log[Slow processing start:
${threadName}] with body null
2017-03-20 16:47:48,930 [ystrix-my-key-1] INFO route5
- Slow processing start: hystrix-my-key-1
2017-03-20 16:47:48,930 [ystrix-my-key-1] INFO
rixRouteBuilderTest$mySlowTest - Before Delay[{3000} ->
[Transform[constant{Slow response}], Log[Slow processing end:
${threadName}]]] with body null
2017-03-20 16:47:50,939 [main ] INFO
rixRouteBuilderTest$mySlowTest -
********************************************************************************
2017-03-20 16:47:50,939 [main ] INFO
rixRouteBuilderTest$mySlowTest - Testing done:
null(HystrixRouteBuilderTest$mySlowTest)
2017-03-20 16:47:50,939 [main ] INFO
rixRouteBuilderTest$mySlowTest - Took: 2.191 seconds (2191 millis)
2017-03-20 16:47:50,939 [main ] INFO
rixRouteBuilderTest$mySlowTest -
********************************************************************************
2017-03-20 16:47:50,943 [main ] INFO DefaultCamelContext
- Apache Camel 2.18.1 (CamelContext: camel-2) is shutting down