Hi,

I would like to use Camel with Perf4j.

I know that Camel JMX already provide statistics but I would like to be
able to easily see at once all my routes performance and be able generate
nice graph. Perf4j allows me to do that quickly (you know another tool that
will do the same with Camel?)

My first try was to extend EventNotifierSupport and react
to ExchangeCreatedEvent and ExchangeCompletedEvent. Basically this:

  public void notify(EventObject event) throws Exception {
    Exchange exchange = (Exchange) event.getSource();
    String tag = exchange.getFromRouteId() + "-" +
exchange.getFromEndpoint();
    if (event instanceof ExchangeCreatedEvent) {
      StopWatch watch = new Slf4JStopWatch(tag);
      exchange.setProperty(STOP_WATCH_KEY + tag, watch);
    } else if (event instanceof ExchangeCompletedEvent) {
      StopWatch watch = (StopWatch) exchange.removeProperty(STOP_WATCH_KEY
+ tag);
      watch.stop();
    }
  }

Of course it doesn't really work. There is no way to have the route id it
seems. Or at least I have strange result. My routes are:

from("sql:...").setRouteId("a").to("direct-foo");
from("direct:foo").setRouteId("b").to("http:...");

And instead of getting something like
Created a
Completed a
Created b
Completed b

I receive something like
Created a-null
Created a-a
Completed a-a
Completed a-a

Any idea why it behaves like this and what I can do?

Thanks
Henri

Reply via email to