Question

On JConsole, We can see following route Statistics.

  1. Minimum / Maximum / Mean Processing Time
  2. First / last Message completion Time
  3. Number of messages failed or re-delivered.
  4. Total number of transaction processed

Requirement: I need to show above data on web page. Below is my code:

public void process(Exchange exchange) throws Exception {

CamelContext context = exchange.getContext();
List<Route> routeObj = context.getRoutes();
for (Route routeId : routeObj) {
    boolean started = context.getRouteStatus(strRouteId).isStarted();
    boolean stopped = context.getRouteStatus(strRouteId).isStopped();
    boolean suspended = context.getRouteStatus(strRouteId).isSuspended();
    // TODO: find min/max/mean processing time, first/last message
    // completion time, etc.
}
}

Thanks in advance.

Please suggest me how to get min/max/mean processing time, first/last message completion time, etc.

No correct solution

OTHER TIPS

See for example the Camel Karaf commands that can dump statistics too. They use the JMX API to do that.

An example is the context-info command: https://github.com/apache/camel/blob/master/platforms/karaf/commands/src/main/java/org/apache/camel/karaf/commands/ContextInfo.java

Apache camel exposes these information using JMX.

A good starting point is the official JMX tutorial and the Apache Camel JMX Documentation

You can actually calculate the info you require, using org.apache.camel.management.PublishEventNotifier

One type of events will get notified of is concerning camel exchanges (like completion, failure...) of each route. The only piece of information you need after that is the processing time of a this exchange (last exchange) which is obtainable using JMX (LastProcessingTime).

Once you have the exchanges processing time for each route, all the information you require can be calculated in real-time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top