You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by William Blackburn <wj...@mac.com> on 2006/04/18 19:05:59 UTC

Custom MsgExchange Listener and JMX

I've written an exchange-listener that also extends BaseSystemService  
and implements its own MBean interface (which extends from  
LifeCycleMBean). I want to have basic manageability of this custom  
service. My config is simply:

<sm:listeners>
      <cmsm:clairmailMessageLogger />
</sm:listeners>

The listener registers fine and that part of it works, however, I  
also want it to be container aware and register as an MBean, this  
part does not work. I'm sure this is actually more of a JMX question,  
but can anyone provide insight into how I would configure such a  
MBean to plug into the smix jmx infrastructure?

Thanks,

BJ.

Re: Custom MsgExchange Listener and JMX

Posted by Guillaume Nodet <gn...@gmail.com>.
This should be now fixed in svn head.
Let me know if there is any problem.

Cheers,
Guillaume Nodet

On 4/19/06, William Blackburn <wj...@mac.com> wrote:
> Guillaume,
> Thank you for your help. Sorry to be such a bother. I've implemented
> as you've suggested, I am getting the container set, and once I have
> it, I am calling init.
>
> I think I am now encountering a 'timing' issue. I am still including
> my object as a 'listener' in the config file. It appears that my
> 'init' is being called before the 'init' of the management context,
> as I am getting a null pointer:
>
> org.springframework.beans.MethodInvocationException: Property
> 'listeners' threw exception; nested exception is
> java.lang.NullPointerException: null
> java.lang.NullPointerException
>          at
> org.apache.servicemix.jbi.management.ManagementContext.createObjectNameP
> rops(ManagementContext.java:441)
>          at
> org.apache.servicemix.jbi.management.ManagementContext.createObjectName(
> ManagementContext.java:369)
>          at
> org.apache.servicemix.jbi.management.ManagementContext.registerSystemSer
> vice(ManagementContext.java:565)
>          at
> org.apache.servicemix.jbi.management.BaseSystemService.init
> (BaseSystemService.java:51)
>          at
> com.clairmail.extensions.servicemix.ClairmailMessageLogger.setContainer(
> ClairmailMessageLogger.java:69)
>
>
> line 441 in management context is:
>          result.put("ContainerName", container.getName());
>
> so it would appear that 'container'  has not yet been set. Forgive
> what may be a dumb question, is there a way to set dependency or
> ordering such that my object doesn't get inited until everything else
> has been inited? Is there a better way to approach this?
>
> Thanks again,
>
> BJ.
>
>
> On Apr 18, 2006, at 4:29 PM, Guillaume Nodet wrote:
>
> > You will also need to implement the
> > org.apache.servicemix.jbi.container.ContainerAware interface and call
> > the init method when you receive the container object.
> >
> > Guillaume
> >
> > On 4/19/06, Guillaume Nodet <gn...@gmail.com> wrote:
> >> Actually, all the needed code is already in the BaseSystemService
> >> class.
> >> You just have to call init(JBIContainer) and shutDown() and the
> >> service will register / unregister itself as a JMX MBean.
> >>
> >> Cheers,
> >> Guillaume Nodet
> >>
> >> On 4/18/06, William Blackburn <wj...@mac.com> wrote:
> >>> I've written an exchange-listener that also extends
> >>> BaseSystemService
> >>> and implements its own MBean interface (which extends from
> >>> LifeCycleMBean). I want to have basic manageability of this custom
> >>> service. My config is simply:
> >>>
> >>> <sm:listeners>
> >>>       <cmsm:clairmailMessageLogger />
> >>> </sm:listeners>
> >>>
> >>> The listener registers fine and that part of it works, however, I
> >>> also want it to be container aware and register as an MBean, this
> >>> part does not work. I'm sure this is actually more of a JMX
> >>> question,
> >>> but can anyone provide insight into how I would configure such a
> >>> MBean to plug into the smix jmx infrastructure?
> >>>
> >>> Thanks,
> >>>
> >>> BJ.
> >>>
> >>
>
>

Re: Custom MsgExchange Listener and JMX

Posted by William Blackburn <wj...@mac.com>.
Guillaume,
Thank you for your help. Sorry to be such a bother. I've implemented  
as you've suggested, I am getting the container set, and once I have  
it, I am calling init.

I think I am now encountering a 'timing' issue. I am still including  
my object as a 'listener' in the config file. It appears that my  
'init' is being called before the 'init' of the management context,  
as I am getting a null pointer:

org.springframework.beans.MethodInvocationException: Property  
'listeners' threw exception; nested exception is  
java.lang.NullPointerException: null
java.lang.NullPointerException
         at  
org.apache.servicemix.jbi.management.ManagementContext.createObjectNameP 
rops(ManagementContext.java:441)
         at  
org.apache.servicemix.jbi.management.ManagementContext.createObjectName( 
ManagementContext.java:369)
         at  
org.apache.servicemix.jbi.management.ManagementContext.registerSystemSer 
vice(ManagementContext.java:565)
         at  
org.apache.servicemix.jbi.management.BaseSystemService.init 
(BaseSystemService.java:51)
         at  
com.clairmail.extensions.servicemix.ClairmailMessageLogger.setContainer( 
ClairmailMessageLogger.java:69)


line 441 in management context is:
         result.put("ContainerName", container.getName());

so it would appear that 'container'  has not yet been set. Forgive  
what may be a dumb question, is there a way to set dependency or  
ordering such that my object doesn't get inited until everything else  
has been inited? Is there a better way to approach this?

Thanks again,

BJ.


On Apr 18, 2006, at 4:29 PM, Guillaume Nodet wrote:

> You will also need to implement the
> org.apache.servicemix.jbi.container.ContainerAware interface and call
> the init method when you receive the container object.
>
> Guillaume
>
> On 4/19/06, Guillaume Nodet <gn...@gmail.com> wrote:
>> Actually, all the needed code is already in the BaseSystemService  
>> class.
>> You just have to call init(JBIContainer) and shutDown() and the
>> service will register / unregister itself as a JMX MBean.
>>
>> Cheers,
>> Guillaume Nodet
>>
>> On 4/18/06, William Blackburn <wj...@mac.com> wrote:
>>> I've written an exchange-listener that also extends  
>>> BaseSystemService
>>> and implements its own MBean interface (which extends from
>>> LifeCycleMBean). I want to have basic manageability of this custom
>>> service. My config is simply:
>>>
>>> <sm:listeners>
>>>       <cmsm:clairmailMessageLogger />
>>> </sm:listeners>
>>>
>>> The listener registers fine and that part of it works, however, I
>>> also want it to be container aware and register as an MBean, this
>>> part does not work. I'm sure this is actually more of a JMX  
>>> question,
>>> but can anyone provide insight into how I would configure such a
>>> MBean to plug into the smix jmx infrastructure?
>>>
>>> Thanks,
>>>
>>> BJ.
>>>
>>


Re: Custom MsgExchange Listener and JMX

Posted by Guillaume Nodet <gn...@gmail.com>.
You will also need to implement the
org.apache.servicemix.jbi.container.ContainerAware interface and call
the init method when you receive the container object.

Guillaume

On 4/19/06, Guillaume Nodet <gn...@gmail.com> wrote:
> Actually, all the needed code is already in the BaseSystemService class.
> You just have to call init(JBIContainer) and shutDown() and the
> service will register / unregister itself as a JMX MBean.
>
> Cheers,
> Guillaume Nodet
>
> On 4/18/06, William Blackburn <wj...@mac.com> wrote:
> > I've written an exchange-listener that also extends BaseSystemService
> > and implements its own MBean interface (which extends from
> > LifeCycleMBean). I want to have basic manageability of this custom
> > service. My config is simply:
> >
> > <sm:listeners>
> >       <cmsm:clairmailMessageLogger />
> > </sm:listeners>
> >
> > The listener registers fine and that part of it works, however, I
> > also want it to be container aware and register as an MBean, this
> > part does not work. I'm sure this is actually more of a JMX question,
> > but can anyone provide insight into how I would configure such a
> > MBean to plug into the smix jmx infrastructure?
> >
> > Thanks,
> >
> > BJ.
> >
>

Re: Custom MsgExchange Listener and JMX

Posted by Guillaume Nodet <gn...@gmail.com>.
Actually, all the needed code is already in the BaseSystemService class.
You just have to call init(JBIContainer) and shutDown() and the
service will register / unregister itself as a JMX MBean.

Cheers,
Guillaume Nodet

On 4/18/06, William Blackburn <wj...@mac.com> wrote:
> I've written an exchange-listener that also extends BaseSystemService
> and implements its own MBean interface (which extends from
> LifeCycleMBean). I want to have basic manageability of this custom
> service. My config is simply:
>
> <sm:listeners>
>       <cmsm:clairmailMessageLogger />
> </sm:listeners>
>
> The listener registers fine and that part of it works, however, I
> also want it to be container aware and register as an MBean, this
> part does not work. I'm sure this is actually more of a JMX question,
> but can anyone provide insight into how I would configure such a
> MBean to plug into the smix jmx infrastructure?
>
> Thanks,
>
> BJ.
>