Version 2

    Receiving Cluster Topology Change Notifications


    o.j.h.f.i.HAPartition contains HAMembershipListener interface which provides a hook to listen for membership changes in the partition that you're interested in.




    First, you'd have to create an implementation of this HAMembershipListener implementing its membershipChanged method where you'd inspect the vectors that see whether a new member has joined, left...etc



    Secondly, you'd need to register this listener that you implemented. To do so, you'd first have to get a proxy instance to the MBean controlling this partition, which for cluster-service.xml, this is by default called jboss:service=DefaultPartition. For example:


    MBeanServer server = MBeanServerLocator.locateJBoss();


    ClusterPartitionMBean cluster;


    cluster = (ClusterPartitionMBean) MBeanProxyExt.create(ClusterPartitionMBean.class, "jboss:service=DefaultPartition", server);



    Let's say that your implementation of HAMembershipListener  is called MyHAMembershipListener, then you'd do something like this to register it:


    HAMembershipListener myMembershipListener = new MyHAMembershipListener();





    Your listener is now registered so that i receives notifications of any changes in the cluster membership.