Search in sources :

Example 1 with CamelContextConfiguration

use of org.apache.camel.spring.boot.CamelContextConfiguration in project camel by apache.

the class Application method contextConfiguration.

@Bean
CamelContextConfiguration contextConfiguration() {
    return new CamelContextConfiguration() {

        @Override
        public void beforeApplicationStart(CamelContext context) {
            LOG.info("Configuring Camel metrics on all routes");
            MetricsRoutePolicyFactory fac = new MetricsRoutePolicyFactory();
            fac.setMetricsRegistry(metricRegistry);
            context.addRoutePolicyFactory(fac);
        }

        @Override
        public void afterApplicationStart(CamelContext camelContext) {
        // noop
        }
    };
}
Also used : CamelContext(org.apache.camel.CamelContext) CamelContextConfiguration(org.apache.camel.spring.boot.CamelContextConfiguration) MetricsRoutePolicyFactory(org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory) Bean(org.springframework.context.annotation.Bean)

Example 2 with CamelContextConfiguration

use of org.apache.camel.spring.boot.CamelContextConfiguration in project syndesis by syndesisio.

the class IntegrationRuntimeAutoConfiguration method integrationContextRuntimeConfiguration.

@Bean
public CamelContextConfiguration integrationContextRuntimeConfiguration(Optional<IntegrationLoggingListener> loggingListener) {
    return new CamelContextConfiguration() {

        @Override
        public void beforeApplicationStart(CamelContext camelContext) {
            final String location = configuration.getConfigurationLocation();
            final List<IntegrationStepHandler> handlers = new ArrayList<>();
            // register handlers discovered from application context
            handlers.addAll(integrationStepHandlers);
            // register handlers discovered using service loader
            for (IntegrationStepHandler handler : ServiceLoader.load(IntegrationStepHandler.class, Thread.currentThread().getContextClassLoader())) {
                handlers.add(handler);
            }
            // IntegrationRouteBuilder automatically add known handlers to
            // the list of provided ones, know handlers have priority
            final RouteBuilder routeBuilder = new IntegrationRouteBuilder(location, handlers, loggingListener.isPresent());
            try {
                // Register routes to the camel context
                camelContext.addRoutes(routeBuilder);
            } catch (@SuppressWarnings("PMD.AvoidCatchingGenericException") Exception e) {
                throw new IllegalArgumentException(e);
            }
        }

        @Override
        public void afterApplicationStart(CamelContext camelContext) {
        // noop
        }
    };
}
Also used : CamelContext(org.apache.camel.CamelContext) CamelContextConfiguration(org.apache.camel.spring.boot.CamelContextConfiguration) RouteBuilder(org.apache.camel.builder.RouteBuilder) ArrayList(java.util.ArrayList) Bean(org.springframework.context.annotation.Bean)

Aggregations

CamelContext (org.apache.camel.CamelContext)2 CamelContextConfiguration (org.apache.camel.spring.boot.CamelContextConfiguration)2 Bean (org.springframework.context.annotation.Bean)2 ArrayList (java.util.ArrayList)1 RouteBuilder (org.apache.camel.builder.RouteBuilder)1 MetricsRoutePolicyFactory (org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory)1