Hi See this FAQ http://camel.apache.org/how-can-i-stop-a-route-from-a-route.html
On Mon, Sep 19, 2016 at 1:19 PM, redpower1989 <redpower1...@hotmail.com> wrote: > Hello i am trying to stop the route when the application detects that there > is no database connection. First in camelContect > > <onException> > > <exception>org.springframework.jdbc.CannotGetJdbcConnectionException</exception> > <to uri="direct:stopRoute" /> > </onException> > > > <route id="stopRoute" routePolicyRef="StopRoutePolicy"> > <from uri="direct:stopRoute" /> > <log message="${id}: Database connection lost, message has been stopped" > loggingLevel="DEBUG" /> > <stop /> > </route> > > Inside my stopRoutePolicy bean: > > public void onExchangeBegin(Route route, Exchange exchange) { > CamelContext context = exchange.getContext(); > String routeId = exchange.getFromRouteId(); > if (context.getRouteStatus(routeId) != null && > context.getRouteStatus(routeId).isStarted()) { > try { > > exchange.getContext().getInflightRepository().remove(exchange); > LOG.info("Stopping route: {}", routeId); > context.stopRoute(routeId); > } catch (Exception exception) { > > getExceptionHandler().handleException(exception); > } > } > } > and i am getting this log messages > > Exchange[ID-FC8BG42-49403-1474282224072-1-7] > 19 Sep 2016 11:52:34 StopRoutePolicyDatabase > INFO Stopping route: routeId > 19 Sep 2016 11:52:34 DefaultShutdownStrategy > INFO Starting to graceful shutdown 1 routes (timeout 10 seconds) > 19 Sep 2016 11:52:34 [ext) thread #19 - ShutdownTask DefaultShutdownStrategy > INFO Waiting as there are still 1 inflight and pending exchanges to > comple > te, timeout in 10 seconds. Inflights per route: routeId = 1 > 19 Sep 2016 11:52:35 [ext) thread #19 - ShutdownTask DefaultShutdownStrategy > INFO Waiting as there are still 1 inflight and pending exchanges to > comple > te, timeout in 9 seconds. Inflights per route: routeId = 1 > ... > > 19 Sep 2016 11:52:44 DefaultShutdownStrategy > WARN Timeout occurred during graceful shutdown. Forcing the routes to > be s > hutdown now. Notice: some resources may still be running as graceful > shutdown di > d not complete successfully. > 19 Sep 2016 11:52:44 [ext) thread #19 - ShutdownTask] > DefaultShutdownStrategy > WARN Interrupted while waiting during graceful shutdown, will force > shutdo > wn now. > 19 Sep 2016 11:52:44 [ext) thread #19 - ShutdownTask] > DefaultShutdownStrategy > INFO Route: routeId shutdown complete, was consuming from: En > dpoint > > My question is as i use : > exchange.getContext().getInflightRepository().remove(exchange); > > Still when i am trying to stop the route why am i getting messages that > there is inflight and pending exchanges to complete? How can i avoid this > situation? Also when i use > context.getShutdownStrategy().setTimeout(30); > it does not seems to change the timeout. > > > > -- > View this message in context: > http://camel.465427.n5.nabble.com/Database-route-shutdown-tp5787725.html > Sent from the Camel - Users mailing list archive at Nabble.com. -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2