Registering MBeans in a central MBeanServer

S

Sebastian

Hello there,

I'd like to register MBeans that are local to several applications -
each running in their own JVM - in a central MBeanServer. An operation
invocation on that registered bean (e. g. using a jconsole connected to
the central server) should result in a remote callback (probably via
RMI) to the local bean, which would be registered in its platform
MBeanServer.

In other words, instead of creating a local bean on the central server,
I'd like to create a remote proxy to my application-local bean and
register that, and I'd like the whole remoting stuff to be transparent.
By that I mean I don't want to explicitly start RMI registries in each
application, keep track of the ports in case they run on the same
machine etc.

There used to be (in the year 2005) a "JMXRemote" project on java net, cf.

http://today.java.net/pub/a/today/2005/12/20/introduction-to-jmxremote.html

but that seems defunct. This must be a common requirement, however, I
haven't found anything useful with Google, nor in any of the JMX
tutorials online.

-- Sebastian
 
S

Sebastian

Am 25.04.2012 15:38, schrieb Sebastian:
Hello there,

I'd like to register MBeans that are local to several applications -
each running in their own JVM - in a central MBeanServer. An operation
invocation on that registered bean (e. g. using a jconsole connected to
the central server) should result in a remote callback (probably via
RMI) to the local bean, which would be registered in its platform
MBeanServer.

In other words, instead of creating a local bean on the central server,
I'd like to create a remote proxy to my application-local bean and
register that
[snip]

I ascribe the lack of response to my not actually having asked a
question. Meanwhile, I have implemented something, which has a
surprising behavior. I'll describe the code in some detail below (and
ask a question about it, too).

Consider two JVMs, one "local" and one "central". The local JVM has an
MBean server listening on port 7777 (defined by the system property
com.sun.management.jmxremote.port=7777), the central one has port 6666.

String localUrl = "service:jmx:rmi:///jndi/rmi://"
+ InetAddress.getLocalHost().getHostAddress() + ":7777"
+ "/jmxrmi";

String remoteUrl = "service:jmx:rmi:///jndi/rmi://"
+ "centralServer:6666"
+ "/jmxrmi";

On the local side, I simply register an MBean in the platform MBS:

StandardMBean mbean = new StandardMBean( this,
ComponentController.class, false );
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbs.registerMBean( mbean, oname() );

When I connect with JConsole to port 7777 and call one of the operations
exposed by ComponentController, evertyhing works as expected.

Things start going wrong when I create a bean on the central server.
That bean gets passed the service URL for my local MBS and the local
bean's object name. Here's the code on the local side:

JMXServiceURL centralUrl = new JMXServiceURL( remoteUrl );
JMXConnector connector = JMXConnectorFactory.connect( centralUrl );
MBeanServerConnection conn = connector.getMBeanServerConnection();
conn.createMBean(
"com.test.ComponentControllerCallback",
oname(),
new Object[] { localUrl, oname() },
new String[] { "java.lang.String", "javax.management.ObjectName" } )

The methods in ComponentControllerCallback (which also implements
ComponentController) are supposed to use that information to obtain the
necessary connection to my local bean and call it back.

The very strange thing is that the simple presence of the above code to
create an MBean on a different JVM wreaks havoc with my local MBS. That
is, even if I connect again directly to the MBS on port 7777 (bypassing
the central server), the methods that worked before will now throw
ClassNotFoundExceptions for RMI-based classes. Deleting the above code
snippet will restore correct behavior.

Unfortunately, the class loading behavior of my application is too
complicated to reproduce or describe briefly. It is a composite
application developed with the SCA implementation of Apache Tuscany.

But anyway: Does anyone have any idea what it is about JMX and the above
code that could possibly throw the remote classloading mechanism into
disarray?

I did try reversing the order of local bean registration and remote bean
creation, but to no avail. Could it be the fact that both JVMs run on
the same host? I'm stumped. Perhaps there is an entirely different and
better way to implement my requirement?

-- Sebastian
 
A

Arved Sandstrom

Am 25.04.2012 15:38, schrieb Sebastian:
Hello there,

I'd like to register MBeans that are local to several applications -
each running in their own JVM - in a central MBeanServer. An operation
invocation on that registered bean (e. g. using a jconsole connected to
the central server) should result in a remote callback (probably via
RMI) to the local bean, which would be registered in its platform
MBeanServer.

In other words, instead of creating a local bean on the central server,
I'd like to create a remote proxy to my application-local bean and
register that
[snip]

I ascribe the lack of response to my not actually having asked a
question. Meanwhile, I have implemented something, which has a
surprising behavior. I'll describe the code in some detail below (and
ask a question about it, too).
[ SNIP ]

Well, no, I saw a question in the first post. :) I use JMX a lot and so
it was an interesting problem.

I verified that there are commercial offerings that do this: e.g. Oracle
Coherence.

I'm also thinking that Open DMK with its Cascading (see
http://docs.oracle.com/cd/E19698-01/816-7607/components-35/index.html)
does what you want.

I'll play with your code snippets some, it's interesting stuff.

AHS
 
R

ratornado

Hi
Im also stuck with a problem of registering the mbeans in central mbeanserver.however i think that my problem is not too complex.
Earlier i used to use my local mbeanserver, and thus used registermbean to register my object, but now i have to use creatembean, which uses classnameas a parameter.now im trying to save an array in my mbean object, but as it is accepting class name as its parameter the array wont show up on jconsole. Plz Help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,991
Messages
2,570,212
Members
46,800
Latest member
Tobi1987

Latest Threads

Top