5.6. Configure the MessagingClusterHealthMBean

The MessagingPostOffice uses the KeepOldFailoverMode and NodeStateRefreshInterval parameters to control the interval during which a node must update timestamps to remain part of a cluster. These parameters do not control how a node responds to losing connection to the database.
If a node loses connection to the database, it can not update the timestamp information available to the MessagePostOffice. Even though the node may still be healthy, the cluster has no way of determining the actual state of the node. As a result, the cluster assumes the node has failed and duplicate message delivery can occur.
The MessagingClusterHealthMBean MBean is responsible for monitoring the node state, and stopping and starting a node when it loses connection to the database. When a node is shunned from the cluster and subsequently loses database connectivity, the MBean shuts down the node immediately. The MBean monitors the JGroups status and database status while the node is unavailable, and will restart the node when it detects JGroups and the database connection is restored to normal operation.
To enable this functionality, declare the MessagingClusterHealthMBean MBean in the ServerPeer MBean as an optional-attribute-name attribute of the <depends> directive.
<!-- ServerPeer MBean configuration -->
<mbean code="org.jboss.jms.server.ServerPeer" name="jboss.messaging:service=ServerPeer" xmbean-dd="xmdesc/ServerPeer-xmbean.xml">

<!-- Unique integer ID of the server peer - each cluster node MUST have a unique value -->

  <attribute name="ServerPeerID">0</attribute>
      
<!-- The default JNDI context that queues use when deployed without specifying one --> 
      
  <attribute name="DefaultQueueJNDIContext">/queue</attribute>
      
<!-- The default JNDI context that topics use when deployed without specifying one --> 
      
  <attribute name="DefaultTopicJNDIContext">/topic</attribute>

<!-- XML CONFIG REMOVED FOR READABILITY -->   

  <depends optional-attribute-name="PersistenceManager">
     jboss.messaging:service=PersistenceManager
  </depends>
      
<!-- XML CONFIG REMOVED FOR READABILITY -->

  <depends optional-attribute-name="MessagingClusterHealthMBean">
     jboss.messaging:service=MessagingClusterHealthMBean
  </depends>
          
</mbean>
After declaring the MessagingClusterHealthMBean MBean in the ServerPeer MBean, you need to add the MessagingClusterHealthMBean MBean's configuration.
<!-- MessagingClusterHealthMBean MBean configuration -->
<mbean code="org.jboss.jms.server.MessagingClusterHealthMBean" name="jboss.messaging:service=MessagingClusterHealthMBean" xmbean-dd="xmdesc/MessagingClusterHealthMBean-xmbean.xml">

<!--  The service name of Server Peer  -->
  <attribute name="ServerPeer">jboss.messaging:service=ServerPeer</attribute>

<!--  The service name of Post Office  -->
  <attribute name="PostOffice">jboss.messaging:service=PostOffice</attribute>

<!--  The service name of Persistence Manager  -->
  <attribute name="PersistenceManager">jboss.messaging:service=PersistenceManager</attribute>

</mbean>