@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 } }; }
@Override public void configure() throws Exception { // add dropwizard metrics to all our routes getContext().addRoutePolicyFactory(new MetricsRoutePolicyFactory()); from("timer:foo").id("foo") .delay(simple("${random(0,1000)}")) .log("Foo is done"); from("timer:bar").id("bar") .delay(simple("${random(0,5000)}")) .log("Bar is done"); }
@Bean public MetricsRoutePolicyFactory getMetricsRoutePolicyFactory(){ return new MetricsRoutePolicyFactory(); }