Hi, I'm using Camel 2.11.1 and the *context.getManagementStrategy().addEventNotifier(new EventNotifierSupport() { ... });* to gather event timings for my Camel application.
Everything works fine except I get *two* events fired for every Exchange sent to my trivial test route. The following test case shows this very simply (notice it outputs 4 *ExchangeSentEvent*'s for just 2 requests sent, and my test route only has 1 '.process()' call in it - adding more steps to the route has no effect!): OUTPUT: --------- ID-UKDB1764398-51680-1376228112185-0-2 exchange Exchange[Message: [Body is null]] sent to: Endpoint[direct://testRoute] took: 13 ms. ID-UKDB1764398-51680-1376228112185-0-2 exchange Exchange[Message: [Body is null]] sent to: Endpoint[direct://testRoute] took: 14 ms. ID-UKDB1764398-51680-1376228112185-0-2 exchange Exchange[Message: [Body is null]] sent to: Endpoint[direct://testRoute] took: 1 ms. ID-UKDB1764398-51680-1376228112185-0-2 exchange Exchange[Message: [Body is null]] sent to: Endpoint[direct://testRoute] took: 1 ms. package com.example; import java.util.EventObject; import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.impl.DefaultCamelContext; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.management.event.ExchangeSentEvent; import org.apache.camel.support.EventNotifierSupport; import org.junit.Test; public class SentEventTest { @Test public void testCamel() throws Exception { CamelContext context = new DefaultCamelContext(); final String routeId = "direct://testRoute"; context.addRoutes(new RouteBuilder() { public void configure() { from(routeId) .routeId(routeId) .process(new Processor() { public void process(Exchange exchange) { }; }); } }); context.getManagementStrategy().addEventNotifier( new EventNotifierSupport() { @Override public void notify(final EventObject event) throws Exception { final ExchangeSentEvent sent = (ExchangeSentEvent) event; System.out.println(sent); } public boolean isEnabled(final EventObject event) { return (event instanceof ExchangeSentEvent); } protected void doStart() throws Exception { } protected void doStop() throws Exception { } }); context.start(); ProducerTemplate producer = context.createProducerTemplate(); Exchange testExchange = new DefaultExchange(context); producer.send(routeId, testExchange); producer.send(routeId, testExchange); context.stop(); } } -- View this message in context: http://camel.465427.n5.nabble.com/Bug-with-addEventNotifier-fires-two-exchange-sent-events-for-each-Exchange-sent-tp5737086.html Sent from the Camel - Users mailing list archive at Nabble.com.