You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Martyn Thompson <th...@hotmail.com> on 2007/10/03 15:52:40 UTC

Mina with Spring and JMX

Hi,

I've only been using MINA for 1 day and had great success in getting it
working with the Spring Framework, rewritting an app within 3 days which is
great. I've been able to get the JMX working as per the example and hard
coding but my preference is to use Spring but just can't seem to get the
MINA JMX beans registered as part of the Spring config.

Could someone give the config snippet I've attached and see where I am going
wrong. I've search the forums but can't find an answer

Thanks in advance for all and any help.

Martyn

http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
MINA_Spring_JMX_conf_snippet.txt 
-- 
View this message in context: http://www.nabble.com/Mina-with-Spring-and-JMX-tf4561940s16868.html#a13019309
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Mina with Spring and JMX

Posted by Martyn Thompson <th...@hotmail.com>.
I hadn't tried locateExistingServerIfPossible, but have done now and the
MBeans register. Thank you.

I'm using 1.1.3, but am now looking at the trunk so that I can use the
startCollectingStats method.

Thanks for your time and help.

Martyn


Niklas Therning wrote:
> 
> Ok, seems like IoServiceManager has been changed slightly since 1.0/1.1 
> and you seem to be using MINA from trunk, right?
> 
> Anyways, AFAIKT IoServiceManager won't collect any stats unless you call 
> startCollectingStats() on it. Since this method has been changed to a 
> no-args method in MINA trunk you should be able to call it directly from 
> Spring using init-method. But, I guess your IoServiceManager should show 
> up at least in JConsole regardless of whether startCollectinStats() have 
> been called or not.
> 
> Have you tried setting the locateExistingServerIfPossible property to 
> true on your mbeanServer bean?
> 
> /Niklas
> 
> Martyn Thompson wrote:
>> I tried your suggestion, but that does not work. This only indicates how
>> often to collect the stats and has a default value of 5000 so does not
>> need
>> to be set. 
>>
>> The problem lies in actually registering the IoServiceManager with the
>> the
>> MBeanServer within the Spring config.
>>
>>
>>
>> Niklas Therning wrote:
>>   
>>> I haven't used the JMX stuff myself but from the tutorial it seems like 
>>> you need to tell the IoServiceManager to start collecting stats:
>>>
>>> IoServiceManager serviceManager = new IoServiceManager( acceptor );
>>> serviceManager.startCollectingStats(1000);
>>> MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
>>> ObjectName name = new
>>> ObjectName("mina.example.http.server:type=IoServiceManager");
>>> mbs.registerMBean(serviceManager, name);
>>>
>>> So it seems like you need to call startCollectingStats(...) somehow. I 
>>> don't think you can do this from within Spring (AFAIK init-method cannot 
>>> take parameters). For now you could try to call it programmatically from 
>>> within the MyServer.initialise() method and see if JMX starts working.
>>>
>>> MINA should probably provide some Spring integration for 
>>> IoServiceManager. A IoServieManagerFactoryBean would solve this problem 
>>> I guess. Any contributions are welcome as always.
>>>
>>> HTH
>>>
>>> /Niklas
>>>
>>> Martyn Thompson wrote:
>>>     
>>>> What happens? Nothing. I was expecting the bean "Port81JMX" to be added
>>>> to
>>>> the MBeanServer and viewable in JConsole, but this does not the case
>>>>
>>>> I've created a very basic test example (attached) that sets up the
>>>> server
>>>> to
>>>> listen on port 81. To use, start the Server class and then telnet to
>>>> port
>>>> 81. Anything typed in the console will be echoed back. This is all
>>>> configured in Spring.
>>>>
>>>> All I need to see is the MBeans that are supplied by default with Mina
>>>> by
>>>> configuring them with Spring.
>>>>
>>>> HTH and thanks
>>>>
>>>> http://www.nabble.com/file/p13114900/MinaJmxExample.zip
>>>> MinaJmxExample.zip 
>>>>
>>>>
>>>>
>>>> Niklas Therning wrote:
>>>>   
>>>>       
>>>>> Martyn Thompson wrote:
>>>>>     
>>>>>         
>>>>>> Hi,
>>>>>>
>>>>>> I've only been using MINA for 1 day and had great success in getting
>>>>>> it
>>>>>> working with the Spring Framework, rewritting an app within 3 days
>>>>>> which
>>>>>> is
>>>>>> great. I've been able to get the JMX working as per the example and
>>>>>> hard
>>>>>> coding but my preference is to use Spring but just can't seem to get
>>>>>> the
>>>>>> MINA JMX beans registered as part of the Spring config.
>>>>>>
>>>>>> Could someone give the config snippet I've attached and see where I
>>>>>> am
>>>>>> going
>>>>>> wrong. I've search the forums but can't find an answer
>>>>>>
>>>>>> Thanks in advance for all and any help.
>>>>>>
>>>>>> Martyn
>>>>>>
>>>>>> http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
>>>>>> MINA_Spring_JMX_conf_snippet.txt 
>>>>>>   
>>>>>>       
>>>>>>           
>>>>> Well, what happens? Do you get an exception of some kind? Could you 
>>>>> provide us with your code as well?
>>>>>
>>>>> /Niklas
>>>>>
>>>>>
>>>>>
>>>>>     
>>>>>         
>>>>   
>>>>       
>>>
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Mina-with-Spring-and-JMX-tf4561940s16868.html#a13116721
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Mina with Spring and JMX

Posted by Niklas Therning <ni...@trillian.se>.
Ok, seems like IoServiceManager has been changed slightly since 1.0/1.1 
and you seem to be using MINA from trunk, right?

Anyways, AFAIKT IoServiceManager won't collect any stats unless you call 
startCollectingStats() on it. Since this method has been changed to a 
no-args method in MINA trunk you should be able to call it directly from 
Spring using init-method. But, I guess your IoServiceManager should show 
up at least in JConsole regardless of whether startCollectinStats() have 
been called or not.

Have you tried setting the locateExistingServerIfPossible property to 
true on your mbeanServer bean?

/Niklas

Martyn Thompson wrote:
> I tried your suggestion, but that does not work. This only indicates how
> often to collect the stats and has a default value of 5000 so does not need
> to be set. 
>
> The problem lies in actually registering the IoServiceManager with the the
> MBeanServer within the Spring config.
>
>
>
> Niklas Therning wrote:
>   
>> I haven't used the JMX stuff myself but from the tutorial it seems like 
>> you need to tell the IoServiceManager to start collecting stats:
>>
>> IoServiceManager serviceManager = new IoServiceManager( acceptor );
>> serviceManager.startCollectingStats(1000);
>> MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
>> ObjectName name = new
>> ObjectName("mina.example.http.server:type=IoServiceManager");
>> mbs.registerMBean(serviceManager, name);
>>
>> So it seems like you need to call startCollectingStats(...) somehow. I 
>> don't think you can do this from within Spring (AFAIK init-method cannot 
>> take parameters). For now you could try to call it programmatically from 
>> within the MyServer.initialise() method and see if JMX starts working.
>>
>> MINA should probably provide some Spring integration for 
>> IoServiceManager. A IoServieManagerFactoryBean would solve this problem 
>> I guess. Any contributions are welcome as always.
>>
>> HTH
>>
>> /Niklas
>>
>> Martyn Thompson wrote:
>>     
>>> What happens? Nothing. I was expecting the bean "Port81JMX" to be added
>>> to
>>> the MBeanServer and viewable in JConsole, but this does not the case
>>>
>>> I've created a very basic test example (attached) that sets up the server
>>> to
>>> listen on port 81. To use, start the Server class and then telnet to port
>>> 81. Anything typed in the console will be echoed back. This is all
>>> configured in Spring.
>>>
>>> All I need to see is the MBeans that are supplied by default with Mina by
>>> configuring them with Spring.
>>>
>>> HTH and thanks
>>>
>>> http://www.nabble.com/file/p13114900/MinaJmxExample.zip
>>> MinaJmxExample.zip 
>>>
>>>
>>>
>>> Niklas Therning wrote:
>>>   
>>>       
>>>> Martyn Thompson wrote:
>>>>     
>>>>         
>>>>> Hi,
>>>>>
>>>>> I've only been using MINA for 1 day and had great success in getting it
>>>>> working with the Spring Framework, rewritting an app within 3 days
>>>>> which
>>>>> is
>>>>> great. I've been able to get the JMX working as per the example and
>>>>> hard
>>>>> coding but my preference is to use Spring but just can't seem to get
>>>>> the
>>>>> MINA JMX beans registered as part of the Spring config.
>>>>>
>>>>> Could someone give the config snippet I've attached and see where I am
>>>>> going
>>>>> wrong. I've search the forums but can't find an answer
>>>>>
>>>>> Thanks in advance for all and any help.
>>>>>
>>>>> Martyn
>>>>>
>>>>> http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
>>>>> MINA_Spring_JMX_conf_snippet.txt 
>>>>>   
>>>>>       
>>>>>           
>>>> Well, what happens? Do you get an exception of some kind? Could you 
>>>> provide us with your code as well?
>>>>
>>>> /Niklas
>>>>
>>>>
>>>>
>>>>     
>>>>         
>>>   
>>>       
>>
>>     
>
>   


Re: Mina with Spring and JMX

Posted by Martyn Thompson <th...@hotmail.com>.
I tried your suggestion, but that does not work. This only indicates how
often to collect the stats and has a default value of 5000 so does not need
to be set. 

The problem lies in actually registering the IoServiceManager with the the
MBeanServer within the Spring config.



Niklas Therning wrote:
> 
> I haven't used the JMX stuff myself but from the tutorial it seems like 
> you need to tell the IoServiceManager to start collecting stats:
> 
> IoServiceManager serviceManager = new IoServiceManager( acceptor );
> serviceManager.startCollectingStats(1000);
> MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
> ObjectName name = new
> ObjectName("mina.example.http.server:type=IoServiceManager");
> mbs.registerMBean(serviceManager, name);
> 
> So it seems like you need to call startCollectingStats(...) somehow. I 
> don't think you can do this from within Spring (AFAIK init-method cannot 
> take parameters). For now you could try to call it programmatically from 
> within the MyServer.initialise() method and see if JMX starts working.
> 
> MINA should probably provide some Spring integration for 
> IoServiceManager. A IoServieManagerFactoryBean would solve this problem 
> I guess. Any contributions are welcome as always.
> 
> HTH
> 
> /Niklas
> 
> Martyn Thompson wrote:
>> What happens? Nothing. I was expecting the bean "Port81JMX" to be added
>> to
>> the MBeanServer and viewable in JConsole, but this does not the case
>>
>> I've created a very basic test example (attached) that sets up the server
>> to
>> listen on port 81. To use, start the Server class and then telnet to port
>> 81. Anything typed in the console will be echoed back. This is all
>> configured in Spring.
>>
>> All I need to see is the MBeans that are supplied by default with Mina by
>> configuring them with Spring.
>>
>> HTH and thanks
>>
>> http://www.nabble.com/file/p13114900/MinaJmxExample.zip
>> MinaJmxExample.zip 
>>
>>
>>
>> Niklas Therning wrote:
>>   
>>> Martyn Thompson wrote:
>>>     
>>>> Hi,
>>>>
>>>> I've only been using MINA for 1 day and had great success in getting it
>>>> working with the Spring Framework, rewritting an app within 3 days
>>>> which
>>>> is
>>>> great. I've been able to get the JMX working as per the example and
>>>> hard
>>>> coding but my preference is to use Spring but just can't seem to get
>>>> the
>>>> MINA JMX beans registered as part of the Spring config.
>>>>
>>>> Could someone give the config snippet I've attached and see where I am
>>>> going
>>>> wrong. I've search the forums but can't find an answer
>>>>
>>>> Thanks in advance for all and any help.
>>>>
>>>> Martyn
>>>>
>>>> http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
>>>> MINA_Spring_JMX_conf_snippet.txt 
>>>>   
>>>>       
>>> Well, what happens? Do you get an exception of some kind? Could you 
>>> provide us with your code as well?
>>>
>>> /Niklas
>>>
>>>
>>>
>>>     
>>
>>   
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Mina-with-Spring-and-JMX-tf4561940s16868.html#a13115496
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Mina with Spring and JMX

Posted by Niklas Therning <ni...@trillian.se>.
I haven't used the JMX stuff myself but from the tutorial it seems like 
you need to tell the IoServiceManager to start collecting stats:

IoServiceManager serviceManager = new IoServiceManager( acceptor );
serviceManager.startCollectingStats(1000);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
ObjectName name = new ObjectName("mina.example.http.server:type=IoServiceManager");
mbs.registerMBean(serviceManager, name);

So it seems like you need to call startCollectingStats(...) somehow. I 
don't think you can do this from within Spring (AFAIK init-method cannot 
take parameters). For now you could try to call it programmatically from 
within the MyServer.initialise() method and see if JMX starts working.

MINA should probably provide some Spring integration for 
IoServiceManager. A IoServieManagerFactoryBean would solve this problem 
I guess. Any contributions are welcome as always.

HTH

/Niklas

Martyn Thompson wrote:
> What happens? Nothing. I was expecting the bean "Port81JMX" to be added to
> the MBeanServer and viewable in JConsole, but this does not the case
>
> I've created a very basic test example (attached) that sets up the server to
> listen on port 81. To use, start the Server class and then telnet to port
> 81. Anything typed in the console will be echoed back. This is all
> configured in Spring.
>
> All I need to see is the MBeans that are supplied by default with Mina by
> configuring them with Spring.
>
> HTH and thanks
>
> http://www.nabble.com/file/p13114900/MinaJmxExample.zip MinaJmxExample.zip 
>
>
>
> Niklas Therning wrote:
>   
>> Martyn Thompson wrote:
>>     
>>> Hi,
>>>
>>> I've only been using MINA for 1 day and had great success in getting it
>>> working with the Spring Framework, rewritting an app within 3 days which
>>> is
>>> great. I've been able to get the JMX working as per the example and hard
>>> coding but my preference is to use Spring but just can't seem to get the
>>> MINA JMX beans registered as part of the Spring config.
>>>
>>> Could someone give the config snippet I've attached and see where I am
>>> going
>>> wrong. I've search the forums but can't find an answer
>>>
>>> Thanks in advance for all and any help.
>>>
>>> Martyn
>>>
>>> http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
>>> MINA_Spring_JMX_conf_snippet.txt 
>>>   
>>>       
>> Well, what happens? Do you get an exception of some kind? Could you 
>> provide us with your code as well?
>>
>> /Niklas
>>
>>
>>
>>     
>
>   


Re: Mina with Spring and JMX

Posted by Martyn Thompson <th...@hotmail.com>.
What happens? Nothing. I was expecting the bean "Port81JMX" to be added to
the MBeanServer and viewable in JConsole, but this does not the case

I've created a very basic test example (attached) that sets up the server to
listen on port 81. To use, start the Server class and then telnet to port
81. Anything typed in the console will be echoed back. This is all
configured in Spring.

All I need to see is the MBeans that are supplied by default with Mina by
configuring them with Spring.

HTH and thanks

http://www.nabble.com/file/p13114900/MinaJmxExample.zip MinaJmxExample.zip 



Niklas Therning wrote:
> 
> Martyn Thompson wrote:
>> Hi,
>>
>> I've only been using MINA for 1 day and had great success in getting it
>> working with the Spring Framework, rewritting an app within 3 days which
>> is
>> great. I've been able to get the JMX working as per the example and hard
>> coding but my preference is to use Spring but just can't seem to get the
>> MINA JMX beans registered as part of the Spring config.
>>
>> Could someone give the config snippet I've attached and see where I am
>> going
>> wrong. I've search the forums but can't find an answer
>>
>> Thanks in advance for all and any help.
>>
>> Martyn
>>
>> http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
>> MINA_Spring_JMX_conf_snippet.txt 
>>   
> Well, what happens? Do you get an exception of some kind? Could you 
> provide us with your code as well?
> 
> /Niklas
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Mina-with-Spring-and-JMX-tf4561940s16868.html#a13114900
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.


Re: Mina with Spring and JMX

Posted by Niklas Therning <ni...@trillian.se>.
Martyn Thompson wrote:
> Hi,
>
> I've only been using MINA for 1 day and had great success in getting it
> working with the Spring Framework, rewritting an app within 3 days which is
> great. I've been able to get the JMX working as per the example and hard
> coding but my preference is to use Spring but just can't seem to get the
> MINA JMX beans registered as part of the Spring config.
>
> Could someone give the config snippet I've attached and see where I am going
> wrong. I've search the forums but can't find an answer
>
> Thanks in advance for all and any help.
>
> Martyn
>
> http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
> MINA_Spring_JMX_conf_snippet.txt 
>   
Well, what happens? Do you get an exception of some kind? Could you 
provide us with your code as well?

/Niklas


Re: Mina with Spring and JMX

Posted by Pablo Pita Leira <pa...@pitagoral.com>.
FYI, I provided a chat server example which included a JMX Spring
configuration. The code was attached to this issue:

https://issues.apache.org/jira/browse/DIRMINA-227

Maybe it can be useful to you,

Pablo Pita




Re: Mina with Spring and JMX

Posted by Martyn Thompson <th...@hotmail.com>.
Bump...sorry no replies after 7 days :0(

Martyn Thompson wrote:
> 
> Hi,
> 
> I've only been using MINA for 1 day and had great success in getting it
> working with the Spring Framework, rewritting an app within 3 days which
> is great. I've been able to get the JMX working as per the example and
> hard coding but my preference is to use Spring but just can't seem to get
> the MINA JMX beans registered as part of the Spring config.
> 
> Could someone give the config snippet I've attached and see where I am
> going wrong. I've search the forums but can't find an answer
> 
> Thanks in advance for all and any help.
> 
> Martyn
> 
>  http://www.nabble.com/file/p13019309/MINA_Spring_JMX_conf_snippet.txt
> MINA_Spring_JMX_conf_snippet.txt 
> 

-- 
View this message in context: http://www.nabble.com/Mina-with-Spring-and-JMX-tf4561940s16868.html#a13113576
Sent from the Apache MINA Support Forum mailing list archive at Nabble.com.