You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by smullins7 <sm...@gmail.com> on 2009/03/09 22:16:45 UTC

Adding custom mbeans to camel JMX mbeanserver

Hello, I have custom endpoints developed that I would like to expose as
mbeans through JMX.  Currently, only the attributes of ManagedEndpoint show
up.  What is the easiest way to get a custom endpoint exposed in jmx while
piggy-backing off the existing mbean server/naming strategy/etc supplied by
camel?
-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22421517.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Mar 10, 2009 at 5:27 PM, smullins7 <sm...@gmail.com> wrote:
>
> Hey thanks for the quick reply, I should have said what I've already tried,
> using Spring JMX wiring does not work.  I add the annotations on my custom
> endpoint, then I wire in the mbean server, assembler, etc and i don't see my
> custom endpoint - I still only see the camel mbeans.  I tried using the
> <jmxAgent> in my camelContext to specify my mbean server domain but that had
> no affect.
>
> My endpoint should not be spring wired, my custom component will create the
> endpoint so only my component is spring wired.
I would try to get it working in JConsole without Camel, eg get your
stuff working.
To be visible in org.apache.camel you need to get your stuff
registetered in that domain as well.
So maybe you can get it working in your own domain first so you know it works.

Then you can take it from there to see if you can get it under the
org.apache.camel domain.


>
>
> Claus Ibsen-2 wrote:
>>
>> On Mon, Mar 9, 2009 at 10:16 PM, smullins7 <sm...@gmail.com> wrote:
>>>
>>> Hello, I have custom endpoints developed that I would like to expose as
>>> mbeans through JMX.  Currently, only the attributes of ManagedEndpoint
>>> show
>>> up.  What is the easiest way to get a custom endpoint exposed in jmx
>>> while
>>> piggy-backing off the existing mbean server/naming strategy/etc supplied
>>> by
>>> camel?
>> As an Endpoint is just an Object I assume you can using standard
>> Spring JMX to expose attributes to JMX.
>> And then use the spring XML stuff to register.
>>
>> To use you custom endpoint in Camel just declare it as a spring bean with
>> and id
>>
>> <bean id="myEndpoint" ...>
>>
>> <from uri="activemq:queue:foo"/>
>> <to ref="myEndpoint"/>
>>
>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22421517.html
>>> Sent from the Camel - Users (activemq) mailing list archive at
>>> Nabble.com.
>>>
>>>
>>
>>
>>
>> --
>> Claus Ibsen
>> Apache Camel Committer
>>
>> Open Source Integration: http://fusesource.com
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22438097.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Adding custom mbeans to camel JMX mbeanserver

Posted by smullins7 <sm...@gmail.com>.
Ok I attached the patch to the Jira issue.


smullins7 wrote:
> 
> Nevermind, just read in the docs that I should attach my fix to the jira
> and fire off an email to the forum group :)
> 
> smullins7 wrote:
>> 
>> I created CAMEL-1450; I can't actually assign this to anyone but mind if
>> I take a stab at it?  Should I comment on the jira or this thread when I
>> have something ready for review?
>> 
>> 
>> James.Strachan wrote:
>>> 
>>> 2009/3/11 smullins7 <sm...@gmail.com>:
>>>>
>>>> Yep that sounds fine to me.  Should I create a jira for this?  I
>>>> haven't read
>>>> any information for developers on this project yet (will do that right
>>>> now).
>>> 
>>> Yes please! :). More details on contributing here...
>>> http://camel.apache.org/contributing.html
>>> 
>>> See if implementing ManagedEndpoint helps you get the JMX registration
>>> 
>>> -- 
>>> James
>>> -------
>>> http://macstrac.blogspot.com/
>>> 
>>> Open Source Integration
>>> http://fusesource.com/
>>> 
>>> 
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22501822.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by smullins7 <sm...@gmail.com>.
Nevermind, just read in the docs that I should attach my fix to the jira and
fire off an email to the forum group :)

smullins7 wrote:
> 
> I created CAMEL-1450; I can't actually assign this to anyone but mind if I
> take a stab at it?  Should I comment on the jira or this thread when I
> have something ready for review?
> 
> 
> James.Strachan wrote:
>> 
>> 2009/3/11 smullins7 <sm...@gmail.com>:
>>>
>>> Yep that sounds fine to me.  Should I create a jira for this?  I haven't
>>> read
>>> any information for developers on this project yet (will do that right
>>> now).
>> 
>> Yes please! :). More details on contributing here...
>> http://camel.apache.org/contributing.html
>> 
>> See if implementing ManagedEndpoint helps you get the JMX registration
>> 
>> -- 
>> James
>> -------
>> http://macstrac.blogspot.com/
>> 
>> Open Source Integration
>> http://fusesource.com/
>> 
>> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22461841.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by smullins7 <sm...@gmail.com>.
I created CAMEL-1450; I can't actually assign this to anyone but mind if I
take a stab at it?  Should I comment on the jira or this thread when I have
something ready for review?


James.Strachan wrote:
> 
> 2009/3/11 smullins7 <sm...@gmail.com>:
>>
>> Yep that sounds fine to me.  Should I create a jira for this?  I haven't
>> read
>> any information for developers on this project yet (will do that right
>> now).
> 
> Yes please! :). More details on contributing here...
> http://camel.apache.org/contributing.html
> 
> See if implementing ManagedEndpoint helps you get the JMX registration
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://fusesource.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22461571.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by James Strachan <ja...@gmail.com>.
2009/3/11 smullins7 <sm...@gmail.com>:
>
> Yep that sounds fine to me.  Should I create a jira for this?  I haven't read
> any information for developers on this project yet (will do that right now).

Yes please! :). More details on contributing here...
http://camel.apache.org/contributing.html

See if implementing ManagedEndpoint helps you get the JMX registration

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Adding custom mbeans to camel JMX mbeanserver

Posted by smullins7 <sm...@gmail.com>.
Yep that sounds fine to me.  Should I create a jira for this?  I haven't read
any information for developers on this project yet (will do that right now).


Claus Ibsen-2 wrote:
> 
> On Wed, Mar 11, 2009 at 4:35 PM, smullins7 <sm...@gmail.com> wrote:
>>
>> No spring is not creating my endpoint that's probably the problem.  Right
>> now, my custom component creates my custom endpoint.  For the time being
>> I
>> might just register the mbeans myself but I was hoping for a less
>> invasive
>> way to expose these mbeans.
>>
>> I would love to help out, do you have a suggested approach to this
>> problem?
>> Just briefly digging around the DefaultCamelContext and
>> InstrumentationLifecycleStrategy it looks like whenever an endpoint is
>> requested is requested from a uri, the InstrumentationLifecycleStrategy
>> class will wrap that endpoint in a ManagedEndpoint and register the
>> ManagedEndpoint with the mbeanserver.  Maybe there's a way to check if
>> the
>> endpoint is a MangedResource; if it is then register the endpoint, if its
>> not then wrap it in a MangedEndpoint?
> yeah sounds like a good idea: The JDK has API for checking for annotations
> 
> But I would assume a normal instanceof also would do the trick?
> instanceof ManagedResource
> 
>>
>>
>> James.Strachan wrote:
>>>
>>> 2009/3/10 smullins7 <sm...@gmail.com>:
>>>>
>>>> Hey thanks for the quick reply, I should have said what I've already
>>>> tried,
>>>> using Spring JMX wiring does not work.  I add the annotations on my
>>>> custom
>>>> endpoint, then I wire in the mbean server, assembler, etc and i don't
>>>> see
>>>> my
>>>> custom endpoint - I still only see the camel mbeans.  I tried using the
>>>> <jmxAgent> in my camelContext to specify my mbean server domain but
>>>> that
>>>> had
>>>> no affect.
>>>>
>>>> My endpoint should not be spring wired, my custom component will create
>>>> the
>>>> endpoint so only my component is spring wired.
>>>
>>> Are you letting spring create the endpoint instances? I think you will
>>> need to if you want to use Spring's JMX stuff right? Either that or
>>> you might wanna register the endpoints directly with JMX yourself?
>>>
>>> It could be we could refactor the endpoint instrumentation code to
>>> make it easier to create custom mbeans; fancy taking a stab?
>>>
>>> --
>>> James
>>> -------
>>> http://macstrac.blogspot.com/
>>>
>>> Open Source Integration
>>> http://fusesource.com/
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22457739.html
>> Sent from the Camel - Users (activemq) mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22458679.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Mar 11, 2009 at 4:35 PM, smullins7 <sm...@gmail.com> wrote:
>
> No spring is not creating my endpoint that's probably the problem.  Right
> now, my custom component creates my custom endpoint.  For the time being I
> might just register the mbeans myself but I was hoping for a less invasive
> way to expose these mbeans.
>
> I would love to help out, do you have a suggested approach to this problem?
> Just briefly digging around the DefaultCamelContext and
> InstrumentationLifecycleStrategy it looks like whenever an endpoint is
> requested is requested from a uri, the InstrumentationLifecycleStrategy
> class will wrap that endpoint in a ManagedEndpoint and register the
> ManagedEndpoint with the mbeanserver.  Maybe there's a way to check if the
> endpoint is a MangedResource; if it is then register the endpoint, if its
> not then wrap it in a MangedEndpoint?
yeah sounds like a good idea: The JDK has API for checking for annotations

But I would assume a normal instanceof also would do the trick?
instanceof ManagedResource

>
>
> James.Strachan wrote:
>>
>> 2009/3/10 smullins7 <sm...@gmail.com>:
>>>
>>> Hey thanks for the quick reply, I should have said what I've already
>>> tried,
>>> using Spring JMX wiring does not work.  I add the annotations on my
>>> custom
>>> endpoint, then I wire in the mbean server, assembler, etc and i don't see
>>> my
>>> custom endpoint - I still only see the camel mbeans.  I tried using the
>>> <jmxAgent> in my camelContext to specify my mbean server domain but that
>>> had
>>> no affect.
>>>
>>> My endpoint should not be spring wired, my custom component will create
>>> the
>>> endpoint so only my component is spring wired.
>>
>> Are you letting spring create the endpoint instances? I think you will
>> need to if you want to use Spring's JMX stuff right? Either that or
>> you might wanna register the endpoints directly with JMX yourself?
>>
>> It could be we could refactor the endpoint instrumentation code to
>> make it easier to create custom mbeans; fancy taking a stab?
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>>
>
> --
> View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22457739.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/

Re: Adding custom mbeans to camel JMX mbeanserver

Posted by smullins7 <sm...@gmail.com>.
No spring is not creating my endpoint that's probably the problem.  Right
now, my custom component creates my custom endpoint.  For the time being I
might just register the mbeans myself but I was hoping for a less invasive
way to expose these mbeans.

I would love to help out, do you have a suggested approach to this problem? 
Just briefly digging around the DefaultCamelContext and
InstrumentationLifecycleStrategy it looks like whenever an endpoint is
requested is requested from a uri, the InstrumentationLifecycleStrategy
class will wrap that endpoint in a ManagedEndpoint and register the
ManagedEndpoint with the mbeanserver.  Maybe there's a way to check if the
endpoint is a MangedResource; if it is then register the endpoint, if its
not then wrap it in a MangedEndpoint?


James.Strachan wrote:
> 
> 2009/3/10 smullins7 <sm...@gmail.com>:
>>
>> Hey thanks for the quick reply, I should have said what I've already
>> tried,
>> using Spring JMX wiring does not work.  I add the annotations on my
>> custom
>> endpoint, then I wire in the mbean server, assembler, etc and i don't see
>> my
>> custom endpoint - I still only see the camel mbeans.  I tried using the
>> <jmxAgent> in my camelContext to specify my mbean server domain but that
>> had
>> no affect.
>>
>> My endpoint should not be spring wired, my custom component will create
>> the
>> endpoint so only my component is spring wired.
> 
> Are you letting spring create the endpoint instances? I think you will
> need to if you want to use Spring's JMX stuff right? Either that or
> you might wanna register the endpoints directly with JMX yourself?
> 
> It could be we could refactor the endpoint instrumentation code to
> make it easier to create custom mbeans; fancy taking a stab?
> 
> -- 
> James
> -------
> http://macstrac.blogspot.com/
> 
> Open Source Integration
> http://fusesource.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22457739.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by James Strachan <ja...@gmail.com>.
2009/3/10 smullins7 <sm...@gmail.com>:
>
> Hey thanks for the quick reply, I should have said what I've already tried,
> using Spring JMX wiring does not work.  I add the annotations on my custom
> endpoint, then I wire in the mbean server, assembler, etc and i don't see my
> custom endpoint - I still only see the camel mbeans.  I tried using the
> <jmxAgent> in my camelContext to specify my mbean server domain but that had
> no affect.
>
> My endpoint should not be spring wired, my custom component will create the
> endpoint so only my component is spring wired.

Are you letting spring create the endpoint instances? I think you will
need to if you want to use Spring's JMX stuff right? Either that or
you might wanna register the endpoints directly with JMX yourself?

It could be we could refactor the endpoint instrumentation code to
make it easier to create custom mbeans; fancy taking a stab?

-- 
James
-------
http://macstrac.blogspot.com/

Open Source Integration
http://fusesource.com/

Re: Adding custom mbeans to camel JMX mbeanserver

Posted by smullins7 <sm...@gmail.com>.
Hey thanks for the quick reply, I should have said what I've already tried,
using Spring JMX wiring does not work.  I add the annotations on my custom
endpoint, then I wire in the mbean server, assembler, etc and i don't see my
custom endpoint - I still only see the camel mbeans.  I tried using the
<jmxAgent> in my camelContext to specify my mbean server domain but that had
no affect.

My endpoint should not be spring wired, my custom component will create the
endpoint so only my component is spring wired.


Claus Ibsen-2 wrote:
> 
> On Mon, Mar 9, 2009 at 10:16 PM, smullins7 <sm...@gmail.com> wrote:
>>
>> Hello, I have custom endpoints developed that I would like to expose as
>> mbeans through JMX.  Currently, only the attributes of ManagedEndpoint
>> show
>> up.  What is the easiest way to get a custom endpoint exposed in jmx
>> while
>> piggy-backing off the existing mbean server/naming strategy/etc supplied
>> by
>> camel?
> As an Endpoint is just an Object I assume you can using standard
> Spring JMX to expose attributes to JMX.
> And then use the spring XML stuff to register.
> 
> To use you custom endpoint in Camel just declare it as a spring bean with
> and id
> 
> <bean id="myEndpoint" ...>
> 
> <from uri="activemq:queue:foo"/>
> <to ref="myEndpoint"/>
> 
> 
>> --
>> View this message in context:
>> http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22421517.html
>> Sent from the Camel - Users (activemq) mailing list archive at
>> Nabble.com.
>>
>>
> 
> 
> 
> -- 
> Claus Ibsen
> Apache Camel Committer
> 
> Open Source Integration: http://fusesource.com
> Blog: http://davsclaus.blogspot.com/
> 
> 

-- 
View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22438097.html
Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.


Re: Adding custom mbeans to camel JMX mbeanserver

Posted by Claus Ibsen <cl...@gmail.com>.
On Mon, Mar 9, 2009 at 10:16 PM, smullins7 <sm...@gmail.com> wrote:
>
> Hello, I have custom endpoints developed that I would like to expose as
> mbeans through JMX.  Currently, only the attributes of ManagedEndpoint show
> up.  What is the easiest way to get a custom endpoint exposed in jmx while
> piggy-backing off the existing mbean server/naming strategy/etc supplied by
> camel?
As an Endpoint is just an Object I assume you can using standard
Spring JMX to expose attributes to JMX.
And then use the spring XML stuff to register.

To use you custom endpoint in Camel just declare it as a spring bean with and id

<bean id="myEndpoint" ...>

<from uri="activemq:queue:foo"/>
<to ref="myEndpoint"/>


> --
> View this message in context: http://www.nabble.com/Adding-custom-mbeans-to-camel-JMX-mbeanserver-tp22421517p22421517.html
> Sent from the Camel - Users (activemq) mailing list archive at Nabble.com.
>
>



-- 
Claus Ibsen
Apache Camel Committer

Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/