@Override public void beforeStart(CamelContext camelContext) { camelContext.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS); camelContext.getShutdownStrategy().setTimeout(shutdownTimeout); } });
@Override public void beforeApplicationStart(CamelContext camelContext) { camelContext.getShutdownStrategy().setTimeout(1); // no shutdown timeout: camelContext.getShutdownStrategy().setTimeUnit(TimeUnit.NANOSECONDS); camelContext.getShutdownStrategy().setShutdownNowOnTimeout(true); // no pending exchanges }
private static void configureShutdownTimeout(CamelContext context, Object value) { int timeout = Integer.parseInt(value.toString()); context.getShutdownStrategy().setTimeout(timeout); }
@Override public void run() { try { // First give things a bit to rollback if running in a new thread if (spawnNewThread) { Thread.sleep(200); } // Then change the timeout programatically camelContext.getShutdownStrategy().setTimeout(shutdownGracePeriodSeconds); // Finally, stop the context camelContext.stop(); } catch (Exception e) { logger.error(e.getMessage(), e); } } }
private void doUnsubscribe(String deviceId, String topic) throws KuraException { final String internalQueue = buildTopicName(deviceId, topic); try { ShutdownStrategy strategy = this.camelContext.getShutdownStrategy(); if (strategy instanceof DefaultShutdownStrategy) { if (((DefaultShutdownStrategy) strategy).getCurrentShutdownTaskFuture() != null) { logger.info("Skipping cleanup of '{}' since the camel context is being shut down", internalQueue); // we are "in shutdown" and would deadlock return; } } // perform shutdown this.camelContext.stopRoute(internalQueue); this.camelContext.removeRoute(internalQueue); } catch (Exception e) { throw new KuraException(KuraErrorCode.SUBSCRIPTION_ERROR, e, internalQueue); } }
@Validate public void start() throws Exception { camelContext = new DefaultCamelContext(); camelContext.addComponent("activemq", activeMQ.getDefaultActiveMQConnection()); camelContext.addRoutes(this); camelContext.getShutdownStrategy().setTimeout(10); camelContext.getShutdownStrategy().setSuppressLoggingOnTimeout(true); camelContext.start(); camelContext.createProducerTemplate().asyncSendBody("direct:startTimer", ""); init(); }
context.getShutdownStrategy().setTimeout(5); context.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS);
camelContext.getShutdownStrategy().setTimeout(config.getShutdownTimeout()); camelContext.getShutdownStrategy().setSuppressLoggingOnTimeout(config.isShutdownSuppressLoggingOnTimeout()); camelContext.getShutdownStrategy().setShutdownNowOnTimeout(config.isShutdownNowOnTimeout()); camelContext.getShutdownStrategy().setShutdownRoutesInReverseOrder(config.isShutdownRoutesInReverseOrder()); camelContext.getShutdownStrategy().setLogInflightExchangesOnTimeout(config.isShutdownLogInflightExchangesOnTimeout());