Skip to content

Commit

Permalink
EAPSUP-656: Simple workaround
Browse files Browse the repository at this point in the history
* If the useTopology is set to false, reuse the initial connection
  connectors to connect to the broker for recovery.

Jira: https://issues.redhat.com/browse/EAPSUP-656
  • Loading branch information
ehsavoie committed Jan 28, 2022
1 parent 70f2932 commit 19bbe5b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 24 deletions.
Expand Up @@ -16,14 +16,14 @@
*/
package org.jboss.activemq.artemis.wildfly.integration.recovery;

import java.util.Arrays;
import javax.transaction.xa.XAResource;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.service.extensions.xa.recovery.ActiveMQXAResourceWrapper;
import org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig;
Expand Down Expand Up @@ -167,18 +167,18 @@ public void failedDiscovery(WildFlyRecoveryDiscovery failedDiscovery) {
*/
public void nodeUp(XARecoveryConfig listeningConfig,
String nodeID,
Pair<TransportConfiguration, TransportConfiguration> networkConfiguration,
TransportConfiguration[] networkConfiguration,
String username,
String password,
Map<String, String> properties) {

if (recoveries.get(nodeID) == null) {
if (WildFlyActiveMQLogger.LOGGER.isDebugEnabled()) {
WildFlyActiveMQLogger.LOGGER.debug(nodeID + " being registered towards " + networkConfiguration);
WildFlyActiveMQLogger.LOGGER.debug(nodeID + " being registered towards " + Arrays.toString(networkConfiguration));
}

XARecoveryConfig config = new XARecoveryConfig(true,
extractTransportConfiguration(networkConfiguration),
networkConfiguration,
username,
password,
properties,
Expand Down Expand Up @@ -234,15 +234,4 @@ public void run() {
}
}

/**
* @param networkConfiguration
* @return
*/
private TransportConfiguration[] extractTransportConfiguration(Pair<TransportConfiguration, TransportConfiguration> networkConfiguration) {
if (networkConfiguration.getB() != null) {
return new TransportConfiguration[]{networkConfiguration.getA(), networkConfiguration.getB()};
}
return new TransportConfiguration[]{networkConfiguration.getA()};
}

}
Expand Up @@ -16,7 +16,6 @@

import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.ActiveMQExceptionType;
import org.apache.activemq.artemis.api.core.Pair;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.api.core.client.ClusterTopologyListener;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
Expand Down Expand Up @@ -129,14 +128,22 @@ public InternalListener(final XARecoveryConfig config) {

@Override
public void nodeUP(TopologyMember topologyMember, boolean last) {
// There is a case where the backup announce itself,
// we need to ignore a case where getLive is null
if (topologyMember.getLive() != null) {
Pair<TransportConfiguration, TransportConfiguration> connector
= new Pair<TransportConfiguration, TransportConfiguration>(topologyMember.getLive(), topologyMember.getBackup());

WildFlyActiveMQRecoveryRegistry.getInstance().nodeUp(config, topologyMember.getNodeId(), connector,
config.getUsername(), config.getPassword(), config.getProperties());
if (!config.getLocatorConfig().useTopologyForLoadBalancing) {
WildFlyActiveMQRecoveryRegistry.getInstance().nodeUp(config, topologyMember.getNodeId(),
config.getTransportConfig(), config.getUsername(), config.getPassword(), config.getProperties());
} else {
// There is a case where the backup announce itself,
// we need to ignore a case where getLive is null
if (topologyMember.getLive() != null) {
TransportConfiguration[] connector;
if (topologyMember.getBackup() != null) {
connector = new TransportConfiguration[]{topologyMember.getLive(), topologyMember.getLive()};
} else {
connector = new TransportConfiguration[]{topologyMember.getLive()};
}
WildFlyActiveMQRecoveryRegistry.getInstance().nodeUp(config, topologyMember.getNodeId(), connector,
config.getUsername(), config.getPassword(), config.getProperties());
}
}
}

Expand Down

0 comments on commit 19bbe5b

Please sign in to comment.