camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: How to Get MBean statistics For a Route, E.g. LastExchangeCompletedTimestamp
Date Wed, 07 Apr 2010 12:44:33 GMT
On Wed, Apr 7, 2010 at 2:29 PM, TRACK81 <hmubiz@gmail.com> wrote:
>
> Hi Claus and thank you for the quick reply... I am using 2.2.0 and it its not
> in this release.
> Th curcumvent this i do as following:
>
> --------------------------------------------------------------------------
> List<Route> routes = camelContext.getRoutes();
> for(Route route : routes) {
>        if(route.getId().equals("DaletNotificationRoute")) {
>                ObjectName objectName =
> camelContext.getManagementStrategy().getManagementNamingStrategy().getObjectNameForRoute(route);
>                Object object =
> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer().invoke(objectName,
> "getLastExchangeCompletedTimestamp", null, null);
>                if(object != null) {
>                                        System.out.println("Last Exchange
Timestamp is : " + ((Date)object));
>                }
>        }
> }
>
> --------------------------------------------------------------------------
>
> And this works...:)
> But i am curious if this is the right way of retrieving statistics or there
> is another way?

Yeah that is a good way.

The JMX API is terrible and its also terrible to browse/traverse the MBeans.
So by using the Camel API to get the exact ObjectName for the route
you want stats about is clever.

There is unit tests in camel-core under the management package you can
use as inspiration also.



>
> Best Regards and Thanks in Advance
>
> TRACK81
>
>
>
> Claus Ibsen-2 wrote:
>>
>> CamelContext have a getRoute("id of the route") method.
>> I think its in 2.2.0 also if not its in the next 2.3.0 release.
>>
>>
>> In Java DSL you use .routeId("myRoute") to assign an id to a route.
>> In Spring XML its just the id attribute on the <route> tag.
>>
>>
>>
>> On Wed, Apr 7, 2010 at 1:42 PM, TRACK81 <hmubiz@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>> I am fairly new to Camel and strugling to
>>>
>>> get the statistic LastExchangeCompletedTimestamp for a "specific" route.
>>>
>>> I can get the statistic by using the getRoutes().get(2) using the
>>> following
>>> code:
>>>
>>> -----------------------------------------------------------------------------------------
>>> List<Route> r = camelContext.getRoutes();
>>>
>>> System.out.println("r side: " + r.size());
>>> System.out.println("r side: " + r.get(2).getId());
>>>
>>> ObjectName obj =
>>> camelContext.getManagementStrategy().getManagementNamingStrategy().getObjectNameForRoute(r.get(2));
>>> Object o6 =
>>>
>>> camelContext.getManagementStrategy().getManagementAgent().getMBeanServer().invoke(obj,
>>> "getLastExchangeCompletedTimestamp", null, null);
>>>
>>> if(o6 != null)
>>> System.out.println("Last Exchange Timestamp is : " + ((Date)o6));
>>>
>>> Which prints out:
>>>
>>> Last Exchange Timestamp is : Wed Apr 07 13:38:40 CEST 2010
>>> -----------------------------------------------------------------------------------------
>>>
>>> What i would like is to get a specific Route using its name as a
>>> qualifier,
>>> something like
>>> Route r = camelContext.getRoutes().get("MyRoute");
>>>
>>> But this is not possible, could you please help me with any
>>> suggestions...??
>>>
>>> Best regards in Advance
>>>
>>> TRACK81
>>> --
>>> View this message in context:
>>> http://old.nabble.com/How-to-Get-MBean-statistics-For-a-Route%2C-E.g.-LastExchangeCompletedTimestamp-tp28163769p28163769.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Author of Camel in Action: http://www.manning.com/ibsen/
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>> Twitter: http://twitter.com/davsclaus
>>
>>
>
> --
> View this message in context: http://old.nabble.com/How-to-Get-MBean-statistics-For-a-Route%2C-E.g.-LastExchangeCompletedTimestamp-tp28163769p28164315.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus

Mime
View raw message