How to create multiple instances of an Mbean?

User Rating: 0 / 5

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

 

Supposing you need two instances of an MBean, let's say one for the client and one for the server. The main problem is that the objectName must be unique but you can hack it by adding an id for each MBean.

Here's an example:

<?xml version="1.0" encoding="UTF-8"?>
<server>
  <mbean code="sample.HelloWorldService" name="sample:service=HelloWorld,id=1">
    <attribute name="Message">Hello World Service Client</attribute>
  </mbean>
    <mbean code="sample.HelloWorldService" name="sample:service=HelloWorld,id=2">
    <attribute name="Message">Hello World Service Server</attribute>
  </mbean>
</server>
 

Now you'll see in the JMX console that two instances of the same Service (but with different id) are published.

Related articles available on mastertheboss.com

JBoss MBeans POJO

JMX MBean services are the core building blocks of the JBoss Appl

How to a dump of JNDI tree with JMX console ?

#2 JBoss Howto. This is the recipe of the day

How to configure JBoss to bind to a different IP ?

  If you want to change the jboss.bind.address property use the 

How to shut down JBoss from remote ?

JBoss recipe of the day

JBoss classloader issues

By default JBoss (prior to version 3.2) uses a flat class loading

jboss.xml reference

JBoss xml reference   JBoss AS uses a set of custom xml de

Follow us on Twitter