Search in sources :

Example 1 with MetricsRoutePolicyFactory

use of org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory 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 MetricsRoutePolicyFactory

use of org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory in project syncope by apache.

the class SyncopeCamelContext method getCamelContext.

public CamelContext getCamelContext() {
    synchronized (this) {
        if (camelContext == null) {
            camelContext = ApplicationContextProvider.getBeanFactory().getBean(SpringCamelContext.class);
            camelContext.addRoutePolicyFactory(new MetricsRoutePolicyFactory());
        }
        if (camelContext.getRoutes().isEmpty()) {
            List<CamelRoute> routes = routeDAO.findAll();
            LOG.debug("{} route(s) are going to be loaded ", routes.size());
            loadRouteDefinitions(routes.stream().map(input -> input.getContent()).collect(Collectors.toList()));
        }
    }
    return camelContext;
}
Also used : SpringCamelContext(org.apache.camel.spring.SpringCamelContext) CamelRoute(org.apache.syncope.core.persistence.api.entity.CamelRoute) MetricsRoutePolicyFactory(org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory)

Aggregations

MetricsRoutePolicyFactory (org.apache.camel.component.metrics.routepolicy.MetricsRoutePolicyFactory)2 CamelContext (org.apache.camel.CamelContext)1 SpringCamelContext (org.apache.camel.spring.SpringCamelContext)1 CamelContextConfiguration (org.apache.camel.spring.boot.CamelContextConfiguration)1 CamelRoute (org.apache.syncope.core.persistence.api.entity.CamelRoute)1 Bean (org.springframework.context.annotation.Bean)1