From 8f91af1b5cdf6ce6b0e4572919a9b7653ef05da9 Mon Sep 17 00:00:00 2001 From: Martyn Taylor Date: Tue, 2 Dec 2014 12:58:08 +0000 Subject: [PATCH] ActiveMQ6-6 Factor out WildFly XA Recovery Pulls out WildFly XA Recovery specifics into a different project. Some XA recovery code is still present and is used as integration points for integrating TM XA recovery processes. --- activemq-jms-server/pom.xml | 11 +- .../jms/bridge/impl/JMSBridgeImpl.java | 18 +- .../jms/server/ActiveMQJMSServerLogger.java | 11 - .../recovery/ActiveMQRecoveryRegistry.java | 254 ------------------ .../server/recovery/ActiveMQRegistryBase.java | 75 ------ .../server/recovery/RecoveryDiscovery.java | 236 ---------------- .../ActiveMQRAManagedConnectionFactory.java | 2 +- .../ra/inflow/ActiveMQActivation.java | 2 +- .../activemq/ra/recovery/RecoveryManager.java | 18 +- activemq-service-extensions/pom.xml | 5 + .../xa/recovery/ActiveMQRegistry.java | 17 +- .../xa/recovery/ActiveMQRegistryImpl.java | 60 +++++ .../xa/recovery/ActiveMQXARecoveryLogger.java | 118 ++++++++ .../recovery/ActiveMQXAResourceRecovery.java | 26 +- .../recovery/ActiveMQXAResourceWrapper.java | 87 +++--- .../xa}/recovery/XARecoveryConfig.java | 2 +- tests/byteman-tests/pom.xml | 4 +- .../integration/ra/ResourceAdapterTest.java | 21 +- tests/joram-tests/pom.xml | 4 +- tests/performance-tests/pom.xml | 4 +- tests/soak-tests/pom.xml | 4 +- tests/stress-tests/pom.xml | 4 +- tests/timing-tests/pom.xml | 4 +- 23 files changed, 304 insertions(+), 683 deletions(-) delete mode 100644 activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRecoveryRegistry.java delete mode 100644 activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRegistryBase.java delete mode 100644 activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/RecoveryDiscovery.java rename activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/package-info.java => activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistry.java (74%) create mode 100644 activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistryImpl.java create mode 100644 activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXARecoveryLogger.java rename {activemq-jms-server/src/main/java/org/apache/activemq/jms/server => activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa}/recovery/ActiveMQXAResourceRecovery.java (88%) rename {activemq-jms-server/src/main/java/org/apache/activemq/jms/server => activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa}/recovery/ActiveMQXAResourceWrapper.java (77%) rename {activemq-jms-server/src/main/java/org/apache/activemq/jms/server => activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa}/recovery/XARecoveryConfig.java (98%) diff --git a/activemq-jms-server/pom.xml b/activemq-jms-server/pom.xml index 73215aebf2..246dea3ff8 100644 --- a/activemq-jms-server/pom.xml +++ b/activemq-jms-server/pom.xml @@ -50,13 +50,14 @@ geronimo-ejb_3.0_spec - org.jboss.jbossts.jts - jbossjts-jacorb - true + org.apache.geronimo.specs + geronimo-jta_1.1_spec + 1.1.1 - org.jboss - jboss-transaction-spi + org.apache.activemq + activemq-service-extensions + ${project.version} diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/bridge/impl/JMSBridgeImpl.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/bridge/impl/JMSBridgeImpl.java index 169bce8d9c..fed9420a24 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/bridge/impl/JMSBridgeImpl.java +++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/bridge/impl/JMSBridgeImpl.java @@ -44,6 +44,7 @@ import java.util.Iterator; import java.util.LinkedList; import java.util.Map; import java.util.Map.Entry; +import java.util.ServiceLoader; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; @@ -63,9 +64,10 @@ import org.apache.activemq.jms.client.ActiveMQConnection; import org.apache.activemq.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.jms.client.ActiveMQMessage; import org.apache.activemq.jms.server.ActiveMQJMSServerBundle; -import org.apache.activemq.jms.server.recovery.ActiveMQRegistryBase; -import org.apache.activemq.jms.server.recovery.XARecoveryConfig; import org.apache.activemq.service.extensions.ServiceUtils; +import org.apache.activemq.service.extensions.xa.recovery.ActiveMQRegistry; +import org.apache.activemq.service.extensions.xa.recovery.ActiveMQRegistryImpl; +import org.apache.activemq.service.extensions.xa.recovery.XARecoveryConfig; import org.apache.activemq.utils.ClassloadingUtil; import org.apache.activemq.utils.DefaultSensitiveStringCodec; import org.apache.activemq.utils.PasswordMaskingUtil; @@ -183,7 +185,7 @@ public final class JMSBridgeImpl implements JMSBridge private static final int FORWARD_MODE_NONTX = 2; - private ActiveMQRegistryBase registry; + private ActiveMQRegistry registry; /* * Constructor for MBean @@ -2228,7 +2230,15 @@ public final class JMSBridgeImpl implements JMSBridge { try { - registry = (ActiveMQRegistryBase) safeInitNewInstance(locatorClasse); + ServiceLoader sl = ServiceLoader.load(ActiveMQRegistry.class); + if (sl.iterator().hasNext()) + { + registry = sl.iterator().next(); + } + else + { + registry = ActiveMQRegistryImpl.getInstance(); + } } catch (Throwable e) { diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/ActiveMQJMSServerLogger.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/ActiveMQJMSServerLogger.java index 1fbd0b7aa4..eb97abb99d 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/ActiveMQJMSServerLogger.java +++ b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/ActiveMQJMSServerLogger.java @@ -17,7 +17,6 @@ package org.apache.activemq.jms.server; import org.apache.activemq.api.core.client.ClientSessionFactory; -import org.apache.activemq.jms.server.recovery.XARecoveryConfig; import org.jboss.logging.BasicLogger; import org.jboss.logging.Logger; import org.jboss.logging.annotations.Cause; @@ -90,11 +89,6 @@ public interface ActiveMQJMSServerLogger extends BasicLogger format = Message.Format.MESSAGE_FORMAT) void xaRecoverConnectionError(@Cause Exception e, ClientSessionFactory csf); - @LogMessage(level = Logger.Level.WARN) - @Message(id = 122015, value = "Can not connect to {0} on auto-generated resource recovery", - format = Message.Format.MESSAGE_FORMAT) - void xaRecoverAutoConnectionError(@Cause Throwable e, XARecoveryConfig csf); - @LogMessage(level = Logger.Level.DEBUG) @Message(id = 122016, value = "Error in XA Recovery" , format = Message.Format.MESSAGE_FORMAT) void xaRecoveryError(@Cause Exception e); @@ -104,11 +98,6 @@ public interface ActiveMQJMSServerLogger extends BasicLogger format = Message.Format.MESSAGE_FORMAT) void failedToCorrectHost(@Cause Exception e, String name); - @LogMessage(level = Logger.Level.WARN) - @Message(id = 122018, value = "Could not start recovery discovery on {0}, we will retry every recovery scan until the server is available", - format = Message.Format.MESSAGE_FORMAT) - void xaRecoveryStartError(XARecoveryConfig e); - @LogMessage(level = Logger.Level.ERROR) @Message(id = 124000, value = "key attribute missing for JMS configuration {0}" , format = Message.Format.MESSAGE_FORMAT) void jmsConfigMissingKey(Node e); diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRecoveryRegistry.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRecoveryRegistry.java deleted file mode 100644 index f0fd2e7802..0000000000 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRecoveryRegistry.java +++ /dev/null @@ -1,254 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.jms.server.recovery; - -import javax.transaction.xa.XAResource; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -import org.apache.activemq.api.core.Pair; -import org.apache.activemq.api.core.TransportConfiguration; -import org.apache.activemq.jms.server.ActiveMQJMSServerLogger; -import org.jboss.tm.XAResourceRecovery; - -/** - *

This class is used by the Resource Adapter to register RecoveryDiscovery, which is based on the {@link XARecoveryConfig}

- *

Each outbound or inboud connection will pass the configuration here through by calling the method {@link ActiveMQRecoveryRegistry#register(XARecoveryConfig)}

- *

Later the {@link RecoveryDiscovery} will call {@link ActiveMQRecoveryRegistry#nodeUp(String, Pair, String, String)} - * so we will keep a track of nodes on the cluster - * or nodes where this server is connected to.

- * - * @author clebertsuconic - */ -public class ActiveMQRecoveryRegistry implements XAResourceRecovery -{ - - private static final ActiveMQRecoveryRegistry theInstance = new ActiveMQRecoveryRegistry(); - - private final ConcurrentHashMap configSet = new ConcurrentHashMap(); - - /** - * The list by server id and resource adapter wrapper, what will actually be calling recovery. - * This will be returned by getXAResources - */ - private final ConcurrentHashMap recoveries = new ConcurrentHashMap(); - - /** - * In case of failures, we retry on the next getXAResources - */ - private final Set failedDiscoverySet = new HashSet(); - - private ActiveMQRecoveryRegistry() - { - } - - /** - * This will be called periodically by the Transaction Manager - */ - public XAResource[] getXAResources() - { - try - { - checkFailures(); - - ActiveMQXAResourceWrapper[] resourceArray = new ActiveMQXAResourceWrapper[recoveries.size()]; - resourceArray = recoveries.values().toArray(resourceArray); - - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) - { - ActiveMQJMSServerLogger.LOGGER.debug("\n======================================================================================="); - ActiveMQJMSServerLogger.LOGGER.debug("Returning the following list on getXAREsources:"); - for (Map.Entry entry : recoveries.entrySet()) - { - ActiveMQJMSServerLogger.LOGGER.debug("server-id=" + entry.getKey() + ", value=" + entry.getValue()); - } - ActiveMQJMSServerLogger.LOGGER.debug("=======================================================================================\n"); - } - - return resourceArray; - } - catch (Throwable e) - { - ActiveMQJMSServerLogger.LOGGER.warn(e.getMessage(), e); - return new XAResource[]{}; - } - } - - public static ActiveMQRecoveryRegistry getInstance() - { - return theInstance; - } - - /** - * This will be called by then resource adapters, to register a new discovery - * - * @param resourceConfig - */ - public void register(final XARecoveryConfig resourceConfig) - { - RecoveryDiscovery newInstance = new RecoveryDiscovery(resourceConfig); - RecoveryDiscovery discoveryRecord = configSet.putIfAbsent(resourceConfig, newInstance); - if (discoveryRecord == null) - { - discoveryRecord = newInstance; - discoveryRecord.start(false); - } - // you could have a configuration shared with multiple MDBs or RAs - discoveryRecord.incrementUsage(); - } - - /** - * Reference counts and deactivate a configuration - * Notice: this won't remove the servers since a server may have previous XIDs - * - * @param resourceConfig - */ - public void unRegister(final XARecoveryConfig resourceConfig) - { - RecoveryDiscovery discoveryRecord = configSet.get(resourceConfig); - if (discoveryRecord != null && discoveryRecord.decrementUsage() == 0) - { - discoveryRecord = configSet.remove(resourceConfig); - if (discoveryRecord != null) - { - discoveryRecord.stop(); - } - } - } - - /** - * We need to make sure that all resources are closed, we don't actually do this when a resourceConfig is closed but - * maybe we should. - */ - public void stop() - { - for (RecoveryDiscovery recoveryDiscovery : configSet.values()) - { - recoveryDiscovery.stop(); - } - for (ActiveMQXAResourceWrapper activeMQXAResourceWrapper : recoveries.values()) - { - activeMQXAResourceWrapper.close(); - } - recoveries.clear(); - configSet.clear(); - } - - /** - * in case of a failure the Discovery will register itslef to retry - * - * @param failedDiscovery - */ - public void failedDiscovery(RecoveryDiscovery failedDiscovery) - { - ActiveMQJMSServerLogger.LOGGER.debug("RecoveryDiscovery being set to restart:" + failedDiscovery); - synchronized (failedDiscoverySet) - { - failedDiscoverySet.add(failedDiscovery); - } - } - - /** - * @param nodeID - * @param networkConfiguration - * @param username - * @param password - */ - public void nodeUp(String nodeID, - Pair networkConfiguration, - String username, - String password) - { - - if (recoveries.get(nodeID) == null) - { - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) - { - ActiveMQJMSServerLogger.LOGGER.debug(nodeID + " being registered towards " + networkConfiguration); - } - XARecoveryConfig config = new XARecoveryConfig(true, - extractTransportConfiguration(networkConfiguration), - username, - password); - - ActiveMQXAResourceWrapper wrapper = new ActiveMQXAResourceWrapper(config); - recoveries.putIfAbsent(nodeID, wrapper); - } - } - - public void nodeDown(String nodeID) - { - } - - /** - * this will go through the list of retries - */ - private void checkFailures() - { - final HashSet failures = new HashSet(); - - // it will transfer all the discoveries to a new collection - synchronized (failedDiscoverySet) - { - failures.addAll(failedDiscoverySet); - failedDiscoverySet.clear(); - } - - if (failures.size() > 0) - { - // This shouldn't happen on a regular scenario, however when this retry happens this needs - // to be done on a new thread - Thread t = new Thread("ActiveMQ Recovery Discovery Reinitialization") - { - @Override - public void run() - { - for (RecoveryDiscovery discovery : failures) - { - try - { - ActiveMQJMSServerLogger.LOGGER.debug("Retrying discovery " + discovery); - discovery.start(true); - } - catch (Throwable e) - { - ActiveMQJMSServerLogger.LOGGER.warn(e.getMessage(), e); - } - } - } - }; - - t.start(); - } - } - - /** - * @param networkConfiguration - * @return - */ - private TransportConfiguration[] extractTransportConfiguration(Pair networkConfiguration) - { - if (networkConfiguration.getB() != null) - { - return new TransportConfiguration[]{networkConfiguration.getA(), networkConfiguration.getB()}; - } - return new TransportConfiguration[]{networkConfiguration.getA()}; - } - -} diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRegistryBase.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRegistryBase.java deleted file mode 100644 index 1ed0104bbc..0000000000 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQRegistryBase.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.jms.server.recovery; - -import java.util.concurrent.atomic.AtomicBoolean; - -import org.jboss.tm.XAResourceRecoveryRegistry; - -/** - * This class is a base class for the integration layer where - * This class is used on integration points and this is just a bridge to the real registry at - * {@link ActiveMQRecoveryRegistry} - * - * @author Clebert - * - * - */ -public abstract class ActiveMQRegistryBase -{ - - private final AtomicBoolean started = new AtomicBoolean(false); - - public ActiveMQRegistryBase() - { - } - - - public abstract XAResourceRecoveryRegistry getTMRegistry(); - - public void register(final XARecoveryConfig resourceConfig) - { - init(); - ActiveMQRecoveryRegistry.getInstance().register(resourceConfig); - } - - - - public void unRegister(final XARecoveryConfig resourceConfig) - { - init(); - ActiveMQRecoveryRegistry.getInstance().unRegister(resourceConfig); - } - - public void stop() - { - if (started.compareAndSet(true, false) && getTMRegistry() != null) - { - getTMRegistry().removeXAResourceRecovery(ActiveMQRecoveryRegistry.getInstance()); - ActiveMQRecoveryRegistry.getInstance().stop(); - } - } - - private void init() - { - if (started.compareAndSet(false, true) && getTMRegistry() != null) - { - getTMRegistry().addXAResourceRecovery(ActiveMQRecoveryRegistry.getInstance()); - } - } - -} diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/RecoveryDiscovery.java b/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/RecoveryDiscovery.java deleted file mode 100644 index d314c86a8b..0000000000 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/RecoveryDiscovery.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.activemq.jms.server.recovery; - -import java.util.concurrent.atomic.AtomicInteger; - -import org.apache.activemq.api.core.ActiveMQException; -import org.apache.activemq.api.core.ActiveMQExceptionType; -import org.apache.activemq.api.core.Pair; -import org.apache.activemq.api.core.TransportConfiguration; -import org.apache.activemq.api.core.client.ClusterTopologyListener; -import org.apache.activemq.api.core.client.ServerLocator; -import org.apache.activemq.api.core.client.SessionFailureListener; -import org.apache.activemq.api.core.client.TopologyMember; -import org.apache.activemq.core.client.impl.ClientSessionFactoryInternal; -import org.apache.activemq.jms.server.ActiveMQJMSServerLogger; - -/** - *

This class will have a simple Connection Factory and will listen - * for topology updates.

- *

This Discovery is instantiated by {@link ActiveMQRecoveryRegistry} - * - * @author clebertsuconic - */ -public class RecoveryDiscovery implements SessionFailureListener -{ - - private ServerLocator locator; - private ClientSessionFactoryInternal sessionFactory; - private final XARecoveryConfig config; - private final AtomicInteger usage = new AtomicInteger(0); - private boolean started = false; - - - public RecoveryDiscovery(XARecoveryConfig config) - { - this.config = config; - } - - public synchronized void start(boolean retry) - { - if (!started) - { - ActiveMQJMSServerLogger.LOGGER.debug("Starting RecoveryDiscovery on " + config); - started = true; - - locator = config.createServerLocator(); - locator.disableFinalizeCheck(); - locator.addClusterTopologyListener(new InternalListener(config)); - try - { - sessionFactory = (ClientSessionFactoryInternal) locator.createSessionFactory(); - // We are using the SessionFactoryInternal here directly as we don't have information to connect with an user and password - // on the session as all we want here is to get the topology - // in case of failure we will retry - sessionFactory.addFailureListener(this); - - ActiveMQJMSServerLogger.LOGGER.debug("RecoveryDiscovery started fine on " + config); - } - catch (Exception startupError) - { - if (!retry) - { - ActiveMQJMSServerLogger.LOGGER.xaRecoveryStartError(config); - } - stop(); - ActiveMQRecoveryRegistry.getInstance().failedDiscovery(this); - } - - } - } - - public synchronized void stop() - { - internalStop(); - } - - /** - * we may have several connection factories referencing the same connection recovery entry. - * Because of that we need to make a count of the number of the instances that are referencing it, - * so we will remove it as soon as we are done - */ - public int incrementUsage() - { - return usage.decrementAndGet(); - } - - public int decrementUsage() - { - return usage.incrementAndGet(); - } - - - @Override - protected void finalize() - { - // I don't think it's a good thing to synchronize a method on a finalize, - // hence the internalStop (no sync) call here - internalStop(); - } - - protected void internalStop() - { - if (started) - { - started = false; - try - { - if (sessionFactory != null) - { - sessionFactory.close(); - } - } - catch (Exception ignored) - { - ActiveMQJMSServerLogger.LOGGER.debug(ignored, ignored); - } - - try - { - locator.close(); - } - catch (Exception ignored) - { - ActiveMQJMSServerLogger.LOGGER.debug(ignored, ignored); - } - - sessionFactory = null; - locator = null; - } - } - - - static final class InternalListener implements ClusterTopologyListener - { - private final XARecoveryConfig config; - - public InternalListener(final XARecoveryConfig config) - { - this.config = 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 connector = - new Pair(topologyMember.getLive(), - topologyMember.getBackup()); - ActiveMQRecoveryRegistry.getInstance().nodeUp(topologyMember.getNodeId(), connector, - config.getUsername(), config.getPassword()); - } - } - - @Override - public void nodeDown(long eventUID, String nodeID) - { - // I'm not putting any node down, since it may have previous transactions hanging, however at some point we may - //change it have some sort of timeout for removal - } - - } - - - @Override - public void connectionFailed(ActiveMQException exception, boolean failedOver) - { - if (exception.getType() == ActiveMQExceptionType.DISCONNECTED) - { - ActiveMQJMSServerLogger.LOGGER.warn("being disconnected for server shutdown", exception); - } - else - { - ActiveMQJMSServerLogger.LOGGER.warn("Notified of connection failure in xa discovery, we will retry on the next recovery", - exception); - } - internalStop(); - ActiveMQRecoveryRegistry.getInstance().failedDiscovery(this); - } - - @Override - public void connectionFailed(final ActiveMQException me, boolean failedOver, String scaleDownTargetNodeID) - { - connectionFailed(me, failedOver); - } - - @Override - public void beforeReconnect(ActiveMQException exception) - { - } - - /* (non-Javadoc) - * @see java.lang.Object#toString() - */ - @Override - public String toString() - { - return "RecoveryDiscovery [config=" + config + ", started=" + started + "]"; - } - - @Override - public int hashCode() - { - return config.hashCode(); - } - - @Override - public boolean equals(Object o) - { - if (o == null || (!(o instanceof RecoveryDiscovery))) - { - return false; - } - RecoveryDiscovery discovery = (RecoveryDiscovery) o; - - return config.equals(discovery.config); - } - -} diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAManagedConnectionFactory.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAManagedConnectionFactory.java index 0a3fa9f648..7cd6a483bc 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAManagedConnectionFactory.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQRAManagedConnectionFactory.java @@ -30,7 +30,7 @@ import java.util.Iterator; import java.util.Set; import org.apache.activemq.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.jms.server.recovery.XARecoveryConfig; +import org.apache.activemq.service.extensions.xa.recovery.XARecoveryConfig; /** * ActiveMQ ManagedConnectionFactory diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/ActiveMQActivation.java b/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/ActiveMQActivation.java index 6747758c43..e76313a8df 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/ActiveMQActivation.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/inflow/ActiveMQActivation.java @@ -44,12 +44,12 @@ import org.apache.activemq.api.jms.ActiveMQJMSClient; import org.apache.activemq.core.client.impl.ClientSessionInternal; import org.apache.activemq.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.jms.client.ActiveMQDestination; -import org.apache.activemq.jms.server.recovery.XARecoveryConfig; import org.apache.activemq.ra.ActiveMQRABundle; import org.apache.activemq.ra.ActiveMQRAConnectionFactory; import org.apache.activemq.ra.ActiveMQRALogger; import org.apache.activemq.ra.ActiveMQRaUtils; import org.apache.activemq.ra.ActiveMQResourceAdapter; +import org.apache.activemq.service.extensions.xa.recovery.XARecoveryConfig; import org.apache.activemq.utils.FutureLatch; import org.apache.activemq.utils.SensitiveDataCodec; diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java b/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java index cf8864ad20..8f0754ad7c 100644 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/recovery/RecoveryManager.java @@ -18,12 +18,14 @@ package org.apache.activemq.ra.recovery; import java.security.AccessController; import java.security.PrivilegedAction; +import java.util.ServiceLoader; import java.util.Set; import org.apache.activemq.jms.client.ActiveMQConnectionFactory; -import org.apache.activemq.jms.server.recovery.ActiveMQRegistryBase; -import org.apache.activemq.jms.server.recovery.XARecoveryConfig; import org.apache.activemq.ra.ActiveMQRALogger; +import org.apache.activemq.service.extensions.xa.recovery.ActiveMQRegistry; +import org.apache.activemq.service.extensions.xa.recovery.ActiveMQRegistryImpl; +import org.apache.activemq.service.extensions.xa.recovery.XARecoveryConfig; import org.apache.activemq.utils.ClassloadingUtil; import org.apache.activemq.utils.ConcurrentHashSet; @@ -33,7 +35,7 @@ import org.apache.activemq.utils.ConcurrentHashSet; */ public final class RecoveryManager { - private ActiveMQRegistryBase registry; + private ActiveMQRegistry registry; private static final String RESOURCE_RECOVERY_CLASS_NAMES = "org.jboss.as.messaging.jms.AS7RecoveryRegistry;" + "org.jboss.as.integration.activemq.recovery.AS5RecoveryRegistry"; @@ -97,7 +99,15 @@ public final class RecoveryManager { try { - registry = (ActiveMQRegistryBase) safeInitNewInstance(locatorClasse); + ServiceLoader sl = ServiceLoader.load(ActiveMQRegistry.class); + if (sl.iterator().hasNext()) + { + registry = sl.iterator().next(); + } + else + { + registry = ActiveMQRegistryImpl.getInstance(); + } } catch (Throwable e) { diff --git a/activemq-service-extensions/pom.xml b/activemq-service-extensions/pom.xml index c0072b3d46..524cfdd240 100644 --- a/activemq-service-extensions/pom.xml +++ b/activemq-service-extensions/pom.xml @@ -18,6 +18,11 @@ activemq-core-client ${project.version} + + org.apache.activemq + activemq-jms-client + ${project.version} + org.jboss.logging jboss-logging diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/package-info.java b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistry.java similarity index 74% rename from activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/package-info.java rename to activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistry.java index 43746cfeb3..bb81b238a4 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/package-info.java +++ b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistry.java @@ -14,5 +14,20 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.jms.server.recovery; +package org.apache.activemq.service.extensions.xa.recovery; + +/** + * @author mtaylor + */ + +public interface ActiveMQRegistry +{ + void register(final XARecoveryConfig resourceConfig); + + void unRegister(final XARecoveryConfig resourceConfig); + + void stop(); + + void init(); +} diff --git a/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistryImpl.java b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistryImpl.java new file mode 100644 index 0000000000..2dd787b750 --- /dev/null +++ b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQRegistryImpl.java @@ -0,0 +1,60 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.activemq.service.extensions.xa.recovery; + +/** + * @author mtaylor + */ + +public class ActiveMQRegistryImpl implements ActiveMQRegistry +{ + private static ActiveMQRegistryImpl instance; + + public static ActiveMQRegistry getInstance() + { + if (instance == null) + { + instance = new ActiveMQRegistryImpl(); + } + return instance; + } + + @Override + public void register(XARecoveryConfig resourceConfig) + { + + } + + @Override + public void unRegister(XARecoveryConfig resourceConfig) + { + + } + + @Override + public void stop() + { + + } + + @Override + public void init() + { + + } +} diff --git a/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXARecoveryLogger.java b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXARecoveryLogger.java new file mode 100644 index 0000000000..140504a8e7 --- /dev/null +++ b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXARecoveryLogger.java @@ -0,0 +1,118 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.activemq.service.extensions.xa.recovery; + +import org.apache.activemq.api.core.client.ClientSessionFactory; +import org.jboss.logging.BasicLogger; +import org.jboss.logging.Logger; +import org.jboss.logging.annotations.Cause; +import org.jboss.logging.annotations.LogMessage; +import org.jboss.logging.annotations.Message; +import org.jboss.logging.annotations.MessageLogger; +import org.w3c.dom.Node; + +/** + * @author Andy Taylor + * @author Martyn Taylor + * + * Logger Code 12 + * + * each message id must be 6 digits long starting with 12, the 3rd digit donates the level so + * + * INF0 1 + * WARN 2 + * DEBUG 3 + * ERROR 4 + * TRACE 5 + * FATAL 6 + * + * so an INFO message would be 121000 to 121999 + */ +@MessageLogger(projectCode = "AMQ") +public interface ActiveMQXARecoveryLogger extends BasicLogger +{ + /** + * The default logger. + */ + ActiveMQXARecoveryLogger LOGGER = Logger.getMessageLogger(ActiveMQXARecoveryLogger.class, ActiveMQXARecoveryLogger.class.getPackage().getName()); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 121003, value = "JMS Server Manager Running cached command for {0}" , format = Message.Format.MESSAGE_FORMAT) + void serverRunningCachedCommand(Runnable run); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 121004, value = "JMS Server Manager Caching command for {0} since the JMS Server is not active yet", + format = Message.Format.MESSAGE_FORMAT) + void serverCachingCommand(Object runnable); + + @LogMessage(level = Logger.Level.INFO) + @Message(id = 121005, value = "Invalid \"host\" value \"0.0.0.0\" detected for \"{0}\" connector. Switching to \"{1}\". If this new address is incorrect please manually configure the connector to use the proper one.", + format = Message.Format.MESSAGE_FORMAT) + void invalidHostForConnector(String name, String newHost); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122007, value = "Queue {0} does not exist on the topic {1}. It was deleted manually probably." , format = Message.Format.MESSAGE_FORMAT) + void noQueueOnTopic(String queueName, String name); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122008, value = "XA Recovery can not connect to any ActiveMQ server on recovery {0}" , format = Message.Format.MESSAGE_FORMAT) + void recoveryConnectFailed(String s); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122011, value = "error unbinding {0} from JNDI" , format = Message.Format.MESSAGE_FORMAT) + void jndiUnbindError(@Cause Exception e, String key); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122012, value = "JMS Server Manager error" , format = Message.Format.MESSAGE_FORMAT) + void jmsServerError(@Cause Exception e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122013, value = "Error in XA Recovery recover" , format = Message.Format.MESSAGE_FORMAT) + void xaRecoverError(@Cause Exception e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122014, value = "Notified of connection failure in xa recovery connectionFactory for provider {0} will attempt reconnect on next pass", + format = Message.Format.MESSAGE_FORMAT) + void xaRecoverConnectionError(@Cause Exception e, ClientSessionFactory csf); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122015, value = "Can not connect to {0} on auto-generated resource recovery", + format = Message.Format.MESSAGE_FORMAT) + void xaRecoverAutoConnectionError(@Cause Throwable e, XARecoveryConfig csf); + + @LogMessage(level = Logger.Level.DEBUG) + @Message(id = 122016, value = "Error in XA Recovery" , format = Message.Format.MESSAGE_FORMAT) + void xaRecoveryError(@Cause Exception e); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122017, value = "Tried to correct invalid \"host\" value \"0.0.0.0\" for \"{0}\" connector, but received an exception.", + format = Message.Format.MESSAGE_FORMAT) + void failedToCorrectHost(@Cause Exception e, String name); + + @LogMessage(level = Logger.Level.WARN) + @Message(id = 122018, value = "Could not start recovery discovery on {0}, we will retry every recovery scan until the server is available", + format = Message.Format.MESSAGE_FORMAT) + void xaRecoveryStartError(XARecoveryConfig e); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 124000, value = "key attribute missing for JMS configuration {0}" , format = Message.Format.MESSAGE_FORMAT) + void jmsConfigMissingKey(Node e); + + @LogMessage(level = Logger.Level.ERROR) + @Message(id = 124002, value = "Failed to start JMS deployer" , format = Message.Format.MESSAGE_FORMAT) + void jmsDeployerStartError(@Cause Exception e); +} diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQXAResourceRecovery.java b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java similarity index 88% rename from activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQXAResourceRecovery.java rename to activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java index 4f85925ada..d9f484773e 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQXAResourceRecovery.java +++ b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXAResourceRecovery.java @@ -14,15 +14,13 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.jms.server.recovery; +package org.apache.activemq.service.extensions.xa.recovery; import javax.transaction.xa.XAResource; import java.util.HashMap; import java.util.Map; -import com.arjuna.ats.jta.recovery.XAResourceRecovery; import org.apache.activemq.api.core.TransportConfiguration; -import org.apache.activemq.jms.server.ActiveMQJMSServerLogger; /** * A XAResourceRecovery instance that can be used to recover any JMS provider. @@ -52,9 +50,9 @@ import org.apache.activemq.jms.server.ActiveMQJMSServerLogger; * @author Andy Taylor * @version $Revision: 1.1 $ */ -public class ActiveMQXAResourceRecovery implements XAResourceRecovery +public class ActiveMQXAResourceRecovery { - private final boolean trace = ActiveMQJMSServerLogger.LOGGER.isTraceEnabled(); + private final boolean trace = ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled(); private boolean hasMore; @@ -64,15 +62,15 @@ public class ActiveMQXAResourceRecovery implements XAResourceRecovery { if (trace) { - ActiveMQJMSServerLogger.LOGGER.trace("Constructing ActiveMQXAResourceRecovery"); + ActiveMQXARecoveryLogger.LOGGER.trace("Constructing ActiveMQXAResourceRecovery"); } } public boolean initialise(final String config) { - if (ActiveMQJMSServerLogger.LOGGER.isTraceEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { - ActiveMQJMSServerLogger.LOGGER.trace(this + " intialise: " + config); + ActiveMQXARecoveryLogger.LOGGER.trace(this + " intialise: " + config); } String[] configs = config.split(";"); @@ -92,9 +90,9 @@ public class ActiveMQXAResourceRecovery implements XAResourceRecovery res = new ActiveMQXAResourceWrapper(xaRecoveryConfigs); - if (ActiveMQJMSServerLogger.LOGGER.isTraceEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { - ActiveMQJMSServerLogger.LOGGER.trace(this + " initialised"); + ActiveMQXARecoveryLogger.LOGGER.trace(this + " initialised"); } return true; @@ -102,9 +100,9 @@ public class ActiveMQXAResourceRecovery implements XAResourceRecovery public boolean hasMoreResources() { - if (ActiveMQJMSServerLogger.LOGGER.isTraceEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { - ActiveMQJMSServerLogger.LOGGER.trace(this + " hasMoreResources"); + ActiveMQXARecoveryLogger.LOGGER.trace(this + " hasMoreResources"); } /* @@ -128,9 +126,9 @@ public class ActiveMQXAResourceRecovery implements XAResourceRecovery public XAResource getXAResource() { - if (ActiveMQJMSServerLogger.LOGGER.isTraceEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { - ActiveMQJMSServerLogger.LOGGER.trace(this + " getXAResource"); + ActiveMQXARecoveryLogger.LOGGER.trace(this + " getXAResource"); } return res; diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQXAResourceWrapper.java b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java similarity index 77% rename from activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQXAResourceWrapper.java rename to activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java index a7841ba267..b51cf24fa4 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/ActiveMQXAResourceWrapper.java +++ b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/ActiveMQXAResourceWrapper.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.jms.server.recovery; +package org.apache.activemq.service.extensions.xa.recovery; import java.util.Arrays; @@ -30,7 +30,6 @@ import org.apache.activemq.api.core.client.ClientSessionFactory; import org.apache.activemq.api.core.client.ActiveMQClient; import org.apache.activemq.api.core.client.ServerLocator; import org.apache.activemq.api.core.client.SessionFailureListener; -import org.apache.activemq.jms.server.ActiveMQJMSServerLogger; /** * XAResourceWrapper. @@ -65,9 +64,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList { this.xaRecoveryConfigs = xaRecoveryConfigs; - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Recovery configured with " + Arrays.toString(xaRecoveryConfigs) + + ActiveMQXARecoveryLogger.LOGGER.debug("Recovery configured with " + Arrays.toString(xaRecoveryConfigs) + ", instance=" + System.identityHashCode(this)); } @@ -77,25 +76,25 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList { XAResource xaResource = getDelegate(false); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("looking for recover at " + xaResource + " configuration " + Arrays.toString(this.xaRecoveryConfigs)); + ActiveMQXARecoveryLogger.LOGGER.debug("looking for recover at " + xaResource + " configuration " + Arrays.toString(this.xaRecoveryConfigs)); } try { Xid[] xids = xaResource.recover(flag); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled() && xids != null && xids.length > 0) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled() && xids != null && xids.length > 0) { - ActiveMQJMSServerLogger.LOGGER.debug("Recovering these following IDs " + Arrays.toString(xids) + " at " + this); + ActiveMQXARecoveryLogger.LOGGER.debug("Recovering these following IDs " + Arrays.toString(xids) + " at " + this); } return xids; } catch (XAException e) { - ActiveMQJMSServerLogger.LOGGER.xaRecoverError(e); + ActiveMQXARecoveryLogger.LOGGER.xaRecoverError(e); throw check(e); } } @@ -103,9 +102,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public void commit(final Xid xid, final boolean onePhase) throws XAException { XAResource xaResource = getDelegate(true); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Commit " + xaResource + " xid " + " onePhase=" + onePhase); + ActiveMQXARecoveryLogger.LOGGER.debug("Commit " + xaResource + " xid " + " onePhase=" + onePhase); } try { @@ -120,9 +119,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public void rollback(final Xid xid) throws XAException { XAResource xaResource = getDelegate(true); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Rollback " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("Rollback " + xaResource + " xid "); } try { @@ -137,9 +136,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public void forget(final Xid xid) throws XAException { XAResource xaResource = getDelegate(false); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Forget " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("Forget " + xaResource + " xid "); } try @@ -173,9 +172,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public int prepare(final Xid xid) throws XAException { XAResource xaResource = getDelegate(true); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("prepare " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("prepare " + xaResource + " xid "); } try { @@ -190,9 +189,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public void start(final Xid xid, final int flags) throws XAException { XAResource xaResource = getDelegate(false); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("start " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("start " + xaResource + " xid "); } try { @@ -207,9 +206,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public void end(final Xid xid, final int flags) throws XAException { XAResource xaResource = getDelegate(false); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("end " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("end " + xaResource + " xid "); } try { @@ -224,9 +223,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public int getTransactionTimeout() throws XAException { XAResource xaResource = getDelegate(false); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("getTransactionTimeout " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("getTransactionTimeout " + xaResource + " xid "); } try { @@ -241,9 +240,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList public boolean setTransactionTimeout(final int seconds) throws XAException { XAResource xaResource = getDelegate(false); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("setTransactionTimeout " + xaResource + " xid "); + ActiveMQXARecoveryLogger.LOGGER.debug("setTransactionTimeout " + xaResource + " xid "); } try { @@ -259,14 +258,14 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList { if (me.getType() == ActiveMQExceptionType.DISCONNECTED) { - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("being disconnected for server shutdown", me); + ActiveMQXARecoveryLogger.LOGGER.debug("being disconnected for server shutdown", me); } } else { - ActiveMQJMSServerLogger.LOGGER.xaRecoverConnectionError(me, csf); + ActiveMQXARecoveryLogger.LOGGER.xaRecoverConnectionError(me, csf); } close(); } @@ -312,9 +311,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList { xae.initCause(error); } - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Cannot get connectionFactory XAResource", xae); + ActiveMQXARecoveryLogger.LOGGER.debug("Cannot get connectionFactory XAResource", xae); } throw xae; } @@ -326,9 +325,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList { xae.initCause(error); } - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Cannot get connectionFactory XAResource", xae); + ActiveMQXARecoveryLogger.LOGGER.debug("Cannot get connectionFactory XAResource", xae); } throw xae; } @@ -362,9 +361,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList { continue; } - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug("Trying to connect recovery on " + xaRecoveryConfig + " of " + Arrays.toString(xaRecoveryConfigs)); + ActiveMQXARecoveryLogger.LOGGER.debug("Trying to connect recovery on " + xaRecoveryConfig + " of " + Arrays.toString(xaRecoveryConfigs)); } ClientSession cs = null; @@ -402,10 +401,10 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } catch (Throwable e) { - ActiveMQJMSServerLogger.LOGGER.xaRecoverAutoConnectionError(e, xaRecoveryConfig); - if (ActiveMQJMSServerLogger.LOGGER.isDebugEnabled()) + ActiveMQXARecoveryLogger.LOGGER.xaRecoverAutoConnectionError(e, xaRecoveryConfig); + if (ActiveMQXARecoveryLogger.LOGGER.isDebugEnabled()) { - ActiveMQJMSServerLogger.LOGGER.debug(e.getMessage(), e); + ActiveMQXARecoveryLogger.LOGGER.debug(e.getMessage(), e); } try @@ -415,9 +414,9 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } catch (Throwable ignored) { - if (ActiveMQJMSServerLogger.LOGGER.isTraceEnabled()) + if (ActiveMQXARecoveryLogger.LOGGER.isTraceEnabled()) { - ActiveMQJMSServerLogger.LOGGER.trace(e.getMessage(), ignored); + ActiveMQXARecoveryLogger.LOGGER.trace(e.getMessage(), ignored); } } continue; @@ -432,7 +431,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList return delegate; } - ActiveMQJMSServerLogger.LOGGER.recoveryConnectFailed(Arrays.toString(xaRecoveryConfigs)); + ActiveMQXARecoveryLogger.LOGGER.recoveryConnectFailed(Arrays.toString(xaRecoveryConfigs)); throw new ActiveMQNotConnectedException(); } @@ -480,7 +479,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } catch (Throwable ignorable) { - ActiveMQJMSServerLogger.LOGGER.debug(ignorable.getMessage(), ignorable); + ActiveMQXARecoveryLogger.LOGGER.debug(ignorable.getMessage(), ignorable); } } @@ -492,7 +491,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } catch (Throwable ignorable) { - ActiveMQJMSServerLogger.LOGGER.debug(ignorable.getMessage(), ignorable); + ActiveMQXARecoveryLogger.LOGGER.debug(ignorable.getMessage(), ignorable); } } @@ -504,7 +503,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList } catch (Throwable ignorable) { - ActiveMQJMSServerLogger.LOGGER.debug(ignorable.getMessage(), ignorable); + ActiveMQXARecoveryLogger.LOGGER.debug(ignorable.getMessage(), ignorable); } } } @@ -519,7 +518,7 @@ public class ActiveMQXAResourceWrapper implements XAResource, SessionFailureList */ protected XAException check(final XAException e) throws XAException { - ActiveMQJMSServerLogger.LOGGER.xaRecoveryError(e); + ActiveMQXARecoveryLogger.LOGGER.xaRecoveryError(e); // If any exception happened, we close the connection so we may start fresh diff --git a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/XARecoveryConfig.java b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/XARecoveryConfig.java similarity index 98% rename from activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/XARecoveryConfig.java rename to activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/XARecoveryConfig.java index cf23589b6b..522552816a 100644 --- a/activemq-jms-server/src/main/java/org/apache/activemq/jms/server/recovery/XARecoveryConfig.java +++ b/activemq-service-extensions/src/main/java/org/apache/activemq/service/extensions/xa/recovery/XARecoveryConfig.java @@ -14,7 +14,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package org.apache.activemq.jms.server.recovery; +package org.apache.activemq.service.extensions.xa.recovery; import java.util.Arrays; diff --git a/tests/byteman-tests/pom.xml b/tests/byteman-tests/pom.xml index 02e9d1bddf..0388dc8225 100644 --- a/tests/byteman-tests/pom.xml +++ b/tests/byteman-tests/pom.xml @@ -128,8 +128,8 @@ - org.jboss - jboss-transaction-spi + org.apache.geronimo.specs + geronimo-jta_1.1_spec org.apache.geronimo.components diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/ResourceAdapterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/ResourceAdapterTest.java index d9f7c699e0..74f2ef114c 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/ResourceAdapterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/ra/ResourceAdapterTest.java @@ -22,13 +22,11 @@ import javax.resource.spi.endpoint.MessageEndpoint; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.HashMap; -import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.concurrent.CountDownLatch; import org.apache.activemq.api.core.DiscoveryGroupConfiguration; -import org.apache.activemq.api.core.TransportConfiguration; import org.apache.activemq.api.core.UDPBroadcastGroupConfiguration; import org.apache.activemq.api.core.client.ClientSession; import org.apache.activemq.api.core.client.ClientSessionFactory; @@ -38,11 +36,10 @@ import org.apache.activemq.core.client.impl.ClientSessionFactoryInternal; import org.apache.activemq.core.client.impl.ServerLocatorImpl; import org.apache.activemq.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.jms.client.ActiveMQDestination; -import org.apache.activemq.jms.server.recovery.RecoveryDiscovery; -import org.apache.activemq.jms.server.recovery.XARecoveryConfig; import org.apache.activemq.ra.ActiveMQResourceAdapter; import org.apache.activemq.ra.inflow.ActiveMQActivation; import org.apache.activemq.ra.inflow.ActiveMQActivationSpec; +import org.apache.activemq.service.extensions.xa.recovery.XARecoveryConfig; import org.apache.activemq.tests.unit.ra.MessageEndpointFactory; import org.apache.activemq.tests.util.UnitTestCase; import org.apache.activemq.utils.DefaultSensitiveStringCodec; @@ -707,22 +704,6 @@ public class ResourceAdapterTest extends ActiveMQRATestBase assertTrue(endpoint.released); } - @Test - public void testRecoveryDiscoveryAsKey() throws Exception - { - Set discoverySet = new HashSet(); - String factClass = "org.apache.activemq.core.remoting.impl.netty.NettyConnectorFactory"; - TransportConfiguration transportConfig = new TransportConfiguration(factClass, null, "netty"); - XARecoveryConfig config = new XARecoveryConfig(false, new TransportConfiguration[]{transportConfig}, - null, null); - - RecoveryDiscovery discovery1 = new RecoveryDiscovery(config); - RecoveryDiscovery discovery2 = new RecoveryDiscovery(config); - assertTrue(discoverySet.add(discovery1)); - assertFalse(discoverySet.add(discovery2)); - assertEquals("should have only one in the set", 1, discoverySet.size()); - } - @Override public boolean useSecurity() { diff --git a/tests/joram-tests/pom.xml b/tests/joram-tests/pom.xml index b157500d09..fe78bbc320 100644 --- a/tests/joram-tests/pom.xml +++ b/tests/joram-tests/pom.xml @@ -76,8 +76,8 @@ - org.jboss - jboss-transaction-spi + org.apache.geronimo.specs + geronimo-jta_1.1_spec org.apache.geronimo.components diff --git a/tests/performance-tests/pom.xml b/tests/performance-tests/pom.xml index ea82e65983..224694fcd8 100644 --- a/tests/performance-tests/pom.xml +++ b/tests/performance-tests/pom.xml @@ -90,8 +90,8 @@ - org.jboss - jboss-transaction-spi + org.apache.geronimo.specs + geronimo-jta_1.1_spec org.apache.geronimo.components diff --git a/tests/soak-tests/pom.xml b/tests/soak-tests/pom.xml index b876dc1a71..7846310fcf 100644 --- a/tests/soak-tests/pom.xml +++ b/tests/soak-tests/pom.xml @@ -109,8 +109,8 @@ - org.jboss - jboss-transaction-spi + org.apache.geronimo.specs + geronimo-jta_1.1_spec org.apache.geronimo.components diff --git a/tests/stress-tests/pom.xml b/tests/stress-tests/pom.xml index 9918a61260..9d212c02f0 100644 --- a/tests/stress-tests/pom.xml +++ b/tests/stress-tests/pom.xml @@ -109,8 +109,8 @@ - org.jboss - jboss-transaction-spi + org.apache.geronimo.specs + geronimo-jta_1.1_spec org.apache.geronimo.components diff --git a/tests/timing-tests/pom.xml b/tests/timing-tests/pom.xml index 3b1fb1af7c..b83d46ae08 100644 --- a/tests/timing-tests/pom.xml +++ b/tests/timing-tests/pom.xml @@ -87,8 +87,8 @@ - org.jboss - jboss-transaction-spi + org.apache.geronimo.specs + geronimo-jta_1.1_spec org.apache.geronimo.components