Skip to content
Permalink
Browse files
ARTEMIS-3755 mitigate NPE related to fail-back
  • Loading branch information
jbertram authored and clebertsuconic committed Apr 21, 2022
1 parent 84e68c7 commit 650952ba6737c828948bb5fb979396a8ce33118f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
@@ -1773,6 +1773,11 @@ void slowConsumerDetected(String sessionID,
@Message(id = 222307, value = "The queues element is deprecated and replaced by the addresses element")
void queuesElementDeprecated();

@LogMessage(level = Logger.Level.WARN)
@Message(id = 222308, value = "Unable to listen for incoming fail-back request because {0} is null. Ensure the broker has the proper cluster-connection configuration.",
format = Message.Format.MESSAGE_FORMAT)
void failBackCheckerFailure(String component);



@LogMessage(level = Logger.Level.ERROR)
@@ -35,6 +35,8 @@
import org.apache.activemq.artemis.core.server.NodeManager.LockListener;
import org.apache.activemq.artemis.core.server.NodeManager.NodeManagerException;
import org.apache.activemq.artemis.core.server.QueueFactory;
import org.apache.activemq.artemis.core.server.cluster.ClusterConnection;
import org.apache.activemq.artemis.core.server.cluster.ClusterManager;
import org.apache.activemq.artemis.core.server.cluster.ha.ScaleDownPolicy;
import org.apache.activemq.artemis.core.server.cluster.ha.SharedStoreSlavePolicy;
import org.apache.activemq.artemis.core.server.group.GroupingHandler;
@@ -253,15 +255,29 @@ private class FailbackChecker implements Runnable {
BackupTopologyListener backupListener;

FailbackChecker() {
TransportConfiguration connector = activeMQServer.getClusterManager().getDefaultConnection(null).getConnector();
backupListener = new BackupTopologyListener(activeMQServer.getNodeID().toString(), connector);
activeMQServer.getClusterManager().getDefaultConnection(null).addClusterTopologyListener(backupListener);
ClusterManager clusterManager = activeMQServer.getClusterManager();
if (clusterManager != null) {
ClusterConnection clusterConnection = clusterManager.getDefaultConnection(null);
if (clusterConnection != null) {
TransportConfiguration connector = clusterConnection.getConnector();
if (connector != null) {
backupListener = new BackupTopologyListener(activeMQServer.getNodeID().toString(), connector);
clusterConnection.addClusterTopologyListener(backupListener);
} else {
ActiveMQServerLogger.LOGGER.failBackCheckerFailure("connector");
}
} else {
ActiveMQServerLogger.LOGGER.failBackCheckerFailure("cluster connection");
}
} else {
ActiveMQServerLogger.LOGGER.failBackCheckerFailure("cluster manager");
}
}

@Override
public void run() {
try {
if (!restarting.get() && activeMQServer.getNodeManager().isAwaitingFailback() && backupListener.waitForBackup()) {
if (!restarting.get() && activeMQServer.getNodeManager().isAwaitingFailback() && backupListener != null && backupListener.waitForBackup()) {
if (!restarting.compareAndSet(false, true)) {
return;
}

0 comments on commit 650952b

Please sign in to comment.