Reputation: 75
On JConsole, We can see following route Statistics.
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.
Upvotes: 3
Views: 4137
Reputation: 55760
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
Upvotes: 1
Reputation: 3349
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.
Upvotes: 0