On Fri, Mar 15, 2013 at 12:48 PM, Henri Tremblay
<[email protected]> wrote:
> 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?)
>

Yes hawtio can monitor Camel apps. I suggest to take a look.
In the upcoming 1.1 release there is going to be a new plugin for
showing stats, us
http://hawt.io/

And there is also a tool called CamelWatch
http://sksamuel.github.com/camelwatch/



> 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

You should likely only react to created / completed events. And that
is why you may get a null in the from route.
And when you use the direct component its NOT creating a new Exchange
but routing the existing exchange.
And hence why you wont see events for creating / completed from route b.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
FuseSource is now part of Red Hat
Email: [email protected]
Web: http://fusesource.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Reply via email to