context.getShutdownStrategy().setTimeout(getShutdownTimeout());
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); } } }
@Override public void beforeStart(CamelContext camelContext) { camelContext.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS); camelContext.getShutdownStrategy().setTimeout(shutdownTimeout); } });
private void applyConfiguration() { if (_domain == null || _domain.getProperties() == null) { // no config to apply return; } // set shutdown timeout default - this can still be overriden by domain props getShutdownStrategy().setTimeout(DEFAULT_TIMEOUT); // configure context with domain properties CamelContextConfigurator.configure(this, _domain); }
@Override public void configure() throws Exception { // configure properties component PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); pc.setLocation("classpath:ftp.properties"); // lets shutdown faster in case of in-flight messages stack up getContext().getShutdownStrategy().setTimeout(10); from("{{ftp.server}}") .to("file:target/download") .log("Downloaded file ${file:name} complete."); // use system out so it stand out System.out.println("*********************************************************************************"); System.out.println("Camel will route files from the FTP server: " + getContext().resolvePropertyPlaceholders("{{ftp.server}}") + " to the target/download directory."); System.out.println("You can configure the location of the ftp server in the src/main/resources/ftp.properties file."); System.out.println("Use ctrl + c to stop this application."); System.out.println("*********************************************************************************"); } }
@Override public void configure() throws Exception { // configure properties component PropertiesComponent pc = getContext().getComponent("properties", PropertiesComponent.class); pc.setLocation("classpath:ftp.properties"); // lets shutdown faster in case of in-flight messages stack up getContext().getShutdownStrategy().setTimeout(10); from("file:target/upload?moveFailed=../error") .log("Uploading file ${file:name}") .to("{{ftp.client}}") .log("Uploaded file ${file:name} complete."); // use system out so it stand out System.out.println("*********************************************************************************"); System.out.println("Camel will route files from target/upload directory to the FTP server: " + getContext().resolvePropertyPlaceholders("{{ftp.server}}")); System.out.println("You can configure the location of the ftp server in the src/main/resources/ftp.properties file."); System.out.println("If the file upload fails, then the file is moved to the target/error directory."); System.out.println("Use ctrl + c to stop this application."); System.out.println("*********************************************************************************"); } }
@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 }
@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(); }
@Override public void configure() throws Exception { // lets shutdown quicker getContext().getShutdownStrategy().setTimeout(10); // configure the kafka component to use the broker KafkaComponent kafka = new KafkaComponent(); // you can specify more brokers separated by comma kafka.setBrokers("localhost:9092"); // add component to CamelContext getContext().addComponent("kafka", kafka); // use a timer to trigger every 100 milli seconds and generate a random word // which is sent to kafka from("timer:foo?period=100") .bean(new WordBean()) .to("kafka:words") .to("log:words?groupInterval=1000"); } }
this.context.getShutdownStrategy().setTimeout(10); this.context.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS);
m_camel.getShutdownStrategy().setTimeout(15); m_camel.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS);
context.getShutdownStrategy().setTimeout(5); context.getShutdownStrategy().setTimeUnit(TimeUnit.SECONDS);
camelContext.getShutdownStrategy().setTimeout(config.getShutdownTimeout());