Deprecate JMSServerManager; copy predefined-jms destinations into core config
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/8ab00e05 Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/8ab00e05 Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/8ab00e05 Branch: refs/heads/ARTEMIS-780 Commit: 8ab00e05b19641e675c5d1b198dc729f0456691c Parents: 112d136 Author: jbertram <jbert...@apache.com> Authored: Thu Dec 1 15:59:17 2016 -0600 Committer: jbertram <jbert...@apache.com> Committed: Thu Dec 1 22:31:39 2016 -0600 ---------------------------------------------------------------------- .../artemis/integration/FileBroker.java | 42 ++++++++++++++++++++ .../artemis/jms/server/JMSServerManager.java | 1 + .../config/impl/FileJMSConfiguration.java | 6 +-- .../jms/server/impl/JMSServerManagerImpl.java | 1 + .../core/config/CoreAddressConfiguration.java | 2 +- .../core/config/CoreQueueConfiguration.java | 3 +- .../deployers/impl/FileConfigurationParser.java | 4 +- .../postoffice/impl/SimpleAddressManager.java | 5 +++ .../core/server/impl/ActiveMQServerImpl.java | 1 + 9 files changed, 57 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java ---------------------------------------------------------------------- diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java index 82224b9..0556ccc 100644 --- a/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java +++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/integration/FileBroker.java @@ -18,14 +18,20 @@ package org.apache.activemq.artemis.integration; import java.lang.management.ManagementFactory; import java.util.ArrayList; +import java.util.List; import java.util.Map; +import org.apache.activemq.artemis.core.config.CoreAddressConfiguration; +import org.apache.activemq.artemis.core.config.CoreQueueConfiguration; import org.apache.activemq.artemis.core.config.FileDeploymentManager; import org.apache.activemq.artemis.core.config.impl.FileConfiguration; import org.apache.activemq.artemis.core.server.ActiveMQComponent; import org.apache.activemq.artemis.core.server.ActiveMQServer; +import org.apache.activemq.artemis.core.server.RoutingType; import org.apache.activemq.artemis.dto.ServerDTO; import org.apache.activemq.artemis.integration.bootstrap.ActiveMQBootstrapLogger; +import org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration; +import org.apache.activemq.artemis.jms.server.config.TopicConfiguration; import org.apache.activemq.artemis.jms.server.config.impl.FileJMSConfiguration; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; @@ -52,12 +58,48 @@ public class FileBroker implements Broker { //todo if we start to pullout more configs from the main config then we should pull out the configuration objects from factories if available FileConfiguration configuration = new FileConfiguration(); + + // Keep this as we still want to parse destinations in the <jms> element FileJMSConfiguration jmsConfiguration = new FileJMSConfiguration(); FileDeploymentManager fileDeploymentManager = new FileDeploymentManager(configurationUrl); fileDeploymentManager.addDeployable(configuration).addDeployable(jmsConfiguration); fileDeploymentManager.readConfiguration(); + /** + * This is a bit of a hack for backwards config compatibility since we no longer want to start the broker + * using the JMSServerManager which would normally deploy JMS destinations. Here we take the JMS destination + * configurations from the parsed JMS configuration and add them to the core configuration. + * + * It's also important here that we are adding them to the core ADDRESS configurations as those will be + * deployed first and therefore their configuration will take precedence over other legacy queue configurations + * which are deployed later. This is so we can maintain support for configurations like those found in the + * bridge and divert examples where there are JMS and core queues with the same name (which was itself a bit + * of a hack). + * + * This should be removed when support for the old "jms" configuation element is also removed. + */ + { + for (JMSQueueConfiguration jmsQueueConfig : jmsConfiguration.getQueueConfigurations()) { + List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations(); + coreAddressConfigurations.add(new CoreAddressConfiguration() + .setName(jmsQueueConfig.getName()) + .addRoutingType(RoutingType.ANYCAST) + .addQueueConfiguration(new CoreQueueConfiguration() + .setAddress(jmsQueueConfig.getName()) + .setName(jmsQueueConfig.getName()) + .setFilterString(jmsQueueConfig.getSelector()) + .setRoutingType(RoutingType.ANYCAST))); + } + + for (TopicConfiguration topicConfig : jmsConfiguration.getTopicConfigurations()) { + List<CoreAddressConfiguration> coreAddressConfigurations = configuration.getAddressConfigurations(); + coreAddressConfigurations.add(new CoreAddressConfiguration() + .setName(topicConfig.getName()) + .addRoutingType(RoutingType.MULTICAST)); + } + } + components = fileDeploymentManager.buildService(securityManager, ManagementFactory.getPlatformMBeanServer()); ArrayList<ActiveMQComponent> componentsByStartOrder = getComponentsByStartOrder(components); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java ---------------------------------------------------------------------- diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java index 3284110..ec95324 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/JMSServerManager.java @@ -31,6 +31,7 @@ import org.apache.activemq.artemis.spi.core.naming.BindingRegistry; /** * The JMS Management interface. */ +@Deprecated public interface JMSServerManager extends ActiveMQComponent { String getVersion(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java ---------------------------------------------------------------------- diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java index 0fa203e..09db51f 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/config/impl/FileJMSConfiguration.java @@ -55,18 +55,16 @@ public class FileJMSConfiguration extends JMSConfigurationImpl implements Deploy private static final boolean DEFAULT_QUEUE_DURABILITY = true; - private boolean parsed = false; - @Override public void parse(Element config, URL url) throws Exception { parseConfiguration(config); setConfigurationUrl(url); - parsed = true; } @Override public boolean isParsed() { - return parsed; + // always return false here so that the FileDeploymentManager will not invoke buildService() + return false; } @Override http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java index 8532a92..af03747 100644 --- a/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java +++ b/artemis-jms-server/src/main/java/org/apache/activemq/artemis/jms/server/impl/JMSServerManagerImpl.java @@ -108,6 +108,7 @@ import org.w3c.dom.Element; * If a JMSConfiguration object is used, the JMS resources can not be * redeployed. */ +@Deprecated public class JMSServerManagerImpl implements JMSServerManager, ActivateCallback { private static final String REJECT_FILTER = ActiveMQServerImpl.GENERIC_IGNORED_FILTER; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java index 60d2d02..5d28742 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreAddressConfiguration.java @@ -48,7 +48,7 @@ public class CoreAddressConfiguration implements Serializable { return routingTypes; } - public CoreAddressConfiguration addDeliveryMode(RoutingType routingType) { + public CoreAddressConfiguration addRoutingType(RoutingType routingType) { routingTypes.add(routingType); return this; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java index 350765d..9e0087b 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/CoreQueueConfiguration.java @@ -118,8 +118,9 @@ public class CoreQueueConfiguration implements Serializable { return routingType; } - public void setRoutingType(RoutingType routingType) { + public CoreQueueConfiguration setRoutingType(RoutingType routingType) { this.routingType = routingType; + return this; } @Override http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java index c44fde4..44d1a07 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/deployers/impl/FileConfigurationParser.java @@ -929,10 +929,10 @@ public final class FileConfigurationParser extends XMLConfigurationUtil { for (int j = 0; j < children.getLength(); j++) { Node child = children.item(j); if (child.getNodeName().equals("multicast")) { - addressConfiguration.addDeliveryMode(RoutingType.MULTICAST); + addressConfiguration.addRoutingType(RoutingType.MULTICAST); queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.MULTICAST)); } else if (child.getNodeName().equals("anycast")) { - addressConfiguration.addDeliveryMode(RoutingType.ANYCAST); + addressConfiguration.addRoutingType(RoutingType.ANYCAST); queueConfigurations.addAll(parseQueueConfigurations((Element) child, RoutingType.ANYCAST)); } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java index 5e810d5..8db4f6f 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java @@ -29,6 +29,7 @@ import org.apache.activemq.artemis.core.postoffice.Binding; import org.apache.activemq.artemis.core.postoffice.Bindings; import org.apache.activemq.artemis.core.postoffice.BindingsFactory; import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle; +import org.apache.activemq.artemis.core.server.ActiveMQServerLogger; import org.apache.activemq.artemis.core.server.RoutingType; import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.transaction.Transaction; @@ -190,6 +191,9 @@ public class SimpleAddressManager implements AddressManager { @Override public AddressInfo addOrUpdateAddressInfo(AddressInfo addressInfo) { AddressInfo from = addAddressInfo(addressInfo); + if (from != null) { + ActiveMQServerLogger.LOGGER.info("Address " + addressInfo.getName() + " exists already as " + from + ", updating instead with: " + addressInfo); + } return (from == null) ? addressInfo : updateAddressInfo(from, addressInfo); } @@ -198,6 +202,7 @@ public class SimpleAddressManager implements AddressManager { for (RoutingType routingType : to.getRoutingTypes()) { from.addRoutingType(routingType); } + ActiveMQServerLogger.LOGGER.info("Update result: " + from); return from; } } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/8ab00e05/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java ---------------------------------------------------------------------- diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java index 013bced..aadcba9 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ActiveMQServerImpl.java @@ -2328,6 +2328,7 @@ public class ActiveMQServerImpl implements ActiveMQServer { AddressInfo result = postOffice.addOrUpdateAddressInfo(addressInfo); // TODO: is this the right way to do this? + // TODO: deal with possible duplicates, may be adding new records when old ones already exist long txID = storageManager.generateID(); storageManager.addAddressBinding(txID, addressInfo); storageManager.commitBindings(txID);