/** * Program entry point */ public static void main(String[] args) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("stream:in").to("direct:greetings"); from("direct:greetings").to("stream:out"); } }); context.start(); context.getRoutes().forEach(r -> LOGGER.info(r.toString())); context.stop(); } }
private static void doStopCamelContext(CamelContext context, Service camelContextService) throws Exception { if (camelContextService != null) { if (camelContextService == threadService.get()) { threadService.remove(); } camelContextService.stop(); } else { if (context != null) { if (context == threadCamelContext.get()) { threadCamelContext.remove(); } context.stop(); } } }
/** * A helper method to create a list of Route objects for a given route builder */ public static List<Route> getRouteList(RouteBuilder builder) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(builder); context.start(); List<Route> answer = context.getRoutes(); context.stop(); return answer; }
/** * A helper method to create a list of Route objects for a given route builder */ public static List<Route> getRouteList(RouteBuilder builder) throws Exception { CamelContext context = new DefaultCamelContext(); context.addRoutes(builder); context.start(); List<Route> answer = context.getRoutes(); context.stop(); return answer; }
protected void stopCamel() throws Exception { if (this.context != null) { this.context.stop(); this.context = null; } }
@Override public void run() { try { context.stop(); } catch (Exception cause) { cause.printStackTrace(); } } });
@Override public void run() { if (camelContext != null) { try { camelContext.stop(); } catch (final Exception e) { LOG.warn("Unable to stop CamelContext", e); } } else { LOG.warn("Unable to stop CamelContext, no CamelContext was set!"); } }
@Override public void run() { if (camelContext != null) { try { camelContext.stop(); } catch (final Exception e) { LOG.warn("Unable to stop CamelContext", e); } } else { LOG.warn("Unable to stop CamelContext, no CamelContext was set!"); } }
@Override public void stop(BundleContext bundleContext) throws Exception { log.debug("Stopping bundle {}.", bundleContext.getBundle().getBundleId()); camelContext.stop(); log.debug("Bundle {} stopped.", bundleContext.getBundle().getBundleId()); }
@Override public void stop() throws Exception { // stop Camel template.stop(); camelContext.stop(); }
@Invalidate public void stop() throws Exception { camelContext.stop(); } }
public static void main(String args[]) throws Exception { // create CamelContext CamelContext context = new DefaultCamelContext(); // add our route to the CamelContext context.addRoutes(new MyRouteBuilder()); // start the route and let it do its work context.start(); Thread.sleep(10000); // stop the CamelContext context.stop(); } }
protected void doStopInnerContext() throws Exception { CamelContext context = endpoint.getConfig().getInnerContext(); context.stop(); setStartedInnerContext(false); }
@Override public void dispose(T context) { super.dispose(context); if (!context.getStatus().isStopped()) { logger.info("Camel CDI is stopping Camel context [{}]", context.getName()); try { context.stop(); } catch (Exception cause) { throw wrapRuntimeCamelException(cause); } } }
public static void main(String[] args) throws Exception { CamelContext camelContext = new DefaultCamelContext(); camelContext.addRoutes(new MoveFileRoute()); camelContext.setTracing(true); camelContext.start(); Thread.sleep(100000); camelContext.stop(); } }
public void run() throws Exception { CamelContext context = new DefaultCamelContext(); context.addComponent("properties", new PropertiesComponent("sampleconfig.properties")); context.addRoutes(new OrderRouteBuilder()); context.start(); System.in.read(); context.stop(); }
public void run() throws Exception { CamelContext context = new DefaultCamelContext(); JmsConfiguration jmsConfig = new JmsConfiguration(new ActiveMQConnectionFactory("tcp://localhost:61616")); context.addComponent("jms", new JmsComponent(jmsConfig )); context.setTracing(true); context.addRoutes(new Jms2RestRoute()); context.start(); System.in.read(); context.stop(); }
private void validatePojoOption(CamelContext context) throws Exception { context.start(); Collection<String> names = context.getComponentNames(); assertThat(names).contains("my-sql-proxy"); assertThat(names).contains("sql-my-sql-proxy"); SqlComponent sqlComponent = context.getComponent("sql-my-sql-proxy", SqlComponent.class); DataSource sqlDatasource = sqlComponent.getDataSource(); assertThat(sqlDatasource).isEqualTo(this.ds); Map<String, Endpoint> endpoints = context.getEndpointMap(); assertThat(endpoints).containsKey("sql-my-sql-proxy://select%20from%20dual"); context.stop(); }
@Test(timeout=60000) public void checkDefinedTimeout() throws Exception { System.getProperties().setProperty(CamelRpcClientPreProcessor.CAMEL_JMS_REQUEST_TIMEOUT_PROPERTY, "12345"); CamelContext context = getContext(); CamelRpcRequest<EchoRequest,EchoResponse> wrapper = new CamelRpcRequest<>(new EchoRpcModule(), new EchoRequest()); CamelRpcClientPreProcessor camelRpcClientPreProcessor = new CamelRpcClientPreProcessor(); DefaultExchange defaultExchange = new DefaultExchange(context); defaultExchange.getIn().setBody(wrapper); camelRpcClientPreProcessor.process(defaultExchange); context.stop(); assertEquals(12345L, defaultExchange.getIn().getHeader(CamelRpcConstants.CAMEL_JMS_REQUEST_TIMEOUT_HEADER)); }
@Test(timeout=60000) public void checkUndefinedTimeout() throws Exception { CamelContext context = getContext(); CamelRpcRequest<EchoRequest,EchoResponse> wrapper = new CamelRpcRequest<>(new EchoRpcModule(), new EchoRequest()); CamelRpcClientPreProcessor camelRpcClientPreProcessor = new CamelRpcClientPreProcessor(); DefaultExchange defaultExchange = new DefaultExchange(context); defaultExchange.getIn().setBody(wrapper); camelRpcClientPreProcessor.process(defaultExchange); context.stop(); assertEquals(CamelRpcClientPreProcessor.CAMEL_JMS_REQUEST_TIMEOUT_DEFAULT, defaultExchange.getIn().getHeader(CamelRpcConstants.CAMEL_JMS_REQUEST_TIMEOUT_HEADER)); }