Question

I have several instances of JBoss 5.1 running in clustered mode.

I need to find out a way how to programatacally get a list of all nodes/members (host:port) forming the cluster. This code is supposed to run inside an EJB container.

Thanks for any hints!

Was it helpful?

Solution

You can get this info programatically by querying the JMX MBean server. You will need to query the MBean jboss:partition=DefaultPartition,service=HAPartition and look for the value of the attribute CurrentView. The CurrentView will provide the current nodes in the cluster along with their host/IP address. You can also verify this data by matching it up against the data from the jmx-console for the same MBean.

You can put this logic inside an EJB. One catch you need to be aware of is that you do not want your EJB to be deployed before the clustering service has been deployed and started. Otherwise your EJB might throw exceptions (eg. InstanceNotFoundException). Therefore, add a depends clause for the clustering MBean (jboss:service=DefaultPartition) in your jboss-web.xml for your EJB deployment package.

OTHER TIPS

You can find out the clustering members using a variety of frameworks including JGroups, Infinispan, mod_cluster and JMX. Although this tutorial has been written for the AS7 I believe that most of it can be useful also for AS5 users. Regards

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top