Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 5318 invoked from network); 7 Apr 2010 12:45:19 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 7 Apr 2010 12:45:19 -0000 Received: (qmail 13298 invoked by uid 500); 7 Apr 2010 12:45:19 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 13268 invoked by uid 500); 7 Apr 2010 12:45:19 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 13260 invoked by uid 99); 7 Apr 2010 12:45:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 12:45:19 +0000 X-ASF-Spam-Status: No, hits=-1.0 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of claus.ibsen@gmail.com designates 209.85.220.228 as permitted sender) Received: from [209.85.220.228] (HELO mail-fx0-f228.google.com) (209.85.220.228) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Apr 2010 12:45:15 +0000 Received: by fxm28 with SMTP id 28so1346810fxm.36 for ; Wed, 07 Apr 2010 05:44:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :from:date:received:message-id:subject:to:content-type :content-transfer-encoding; bh=Pgrhdw+rXGYCsrjSiCSBHSw4KtRnKkVLSypK9iTrY/w=; b=hKnY8SXvSy6EVm1wl8qrbrCQRVhsQLLGTr2c82Q007TZRYwznPEzeGDEMEhHbT7rKg xUmHa+3DBp4ZDbX9v0O/3SJcPS/qqw74e31eaEDIrRuBe6a94kZQjDx3o0zlnt4Hkcza 0NSYyjjTz1DKMp2jg+6v9HuNeTy0T9hzQuEN8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type:content-transfer-encoding; b=DlQVQERhhIaOlnn/y3NLvZtLm4RFGrgTssE0q8kfZ3KzDwo8pxIOip7R4bhuSOsvW1 B2Ts0aF0FfM0RBxuCQqXlknGUnSZtI4MMkaIHDGubLEjmNFFs8Kqv9zhbXjGrgm9IClC hAnq4tADX+crtLR6fLrlVDY3OY+jTIoVGzLsk= MIME-Version: 1.0 Received: by 10.223.109.11 with HTTP; Wed, 7 Apr 2010 05:44:33 -0700 (PDT) In-Reply-To: <28164315.post@talk.nabble.com> References: <28163769.post@talk.nabble.com> <28164315.post@talk.nabble.com> From: Claus Ibsen Date: Wed, 7 Apr 2010 14:44:33 +0200 Received: by 10.223.24.148 with SMTP id v20mr9226581fab.43.1270644293499; Wed, 07 Apr 2010 05:44:53 -0700 (PDT) Message-ID: Subject: Re: How to Get MBean statistics For a Route, E.g. LastExchangeCompletedTimestamp To: users@camel.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Wed, Apr 7, 2010 at 2:29 PM, TRACK81 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 routes =3D camelContext.getRoutes(); > for(Route route : routes) { > =A0 =A0 =A0 =A0if(route.getId().equals("DaletNotificationRoute")) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ObjectName objectName =3D > camelContext.getManagementStrategy().getManagementNamingStrategy().getObj= ectNameForRoute(route); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0Object object =3D > camelContext.getManagementStrategy().getManagementAgent().getMBeanServer(= ).invoke(objectName, > "getLastExchangeCompletedTimestamp", null, null); > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0if(object !=3D null) { > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0System.out.println("Last Exchange Timestamp is : " + ((Date)object))= ; > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > =A0 =A0 =A0 =A0} > } > > -------------------------------------------------------------------------= - > > And this works...:) > But i am curious if this is the right way of retrieving statistics or the= re > 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 tag. >> >> >> >> On Wed, Apr 7, 2010 at 1:42 PM, TRACK81 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 r =3D camelContext.getRoutes(); >>> >>> System.out.println("r side: " + r.size()); >>> System.out.println("r side: " + r.get(2).getId()); >>> >>> ObjectName obj =3D >>> camelContext.getManagementStrategy().getManagementNamingStrategy().getO= bjectNameForRoute(r.get(2)); >>> Object o6 =3D >>> >>> camelContext.getManagementStrategy().getManagementAgent().getMBeanServe= r().invoke(obj, >>> "getLastExchangeCompletedTimestamp", null, null); >>> >>> if(o6 !=3D 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 =3D 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.-L= astExchangeCompletedTimestamp-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-stat= istics-For-a-Route%2C-E.g.-LastExchangeCompletedTimestamp-tp28163769p281643= 15.html > Sent from the Camel - Users mailing list archive at Nabble.com. > > --=20 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