activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [7/8] activemq-artemis git commit: More address-settings for new functionality; clean up the API a bit
Date Thu, 08 Dec 2016 16:18:13 GMT
More address-settings for new functionality; clean up the API a bit


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/4a53f9b6
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/4a53f9b6
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/4a53f9b6

Branch: refs/heads/ARTEMIS-780
Commit: 4a53f9b6677fdd2f3a84f6f962af98c12eca50d1
Parents: ae849f5
Author: jbertram <jbertram@apache.com>
Authored: Wed Dec 7 20:45:33 2016 -0600
Committer: jbertram <jbertram@apache.com>
Committed: Thu Dec 8 08:43:49 2016 -0600

----------------------------------------------------------------------
 .../core/client/impl/ClientSessionImpl.java     | 26 ++----
 .../artemis/core/config/impl/Validators.java    | 11 +++
 .../deployers/impl/FileConfigurationParser.java | 24 +++++-
 .../impl/ActiveMQServerControlImpl.java         | 87 +++-----------------
 .../core/server/impl/ActiveMQServerImpl.java    | 20 +++--
 .../core/server/impl/ServerSessionImpl.java     | 11 ++-
 .../core/settings/impl/AddressSettings.java     | 62 +++++++++++++-
 .../resources/schema/artemis-configuration.xsd  | 61 +++++++++++---
 .../core/config/impl/FileConfigurationTest.java |  8 ++
 .../resources/ConfigurationTest-full-config.xml |  8 ++
 10 files changed, 199 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
index 72a2391..fb59237 100644
--- a/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
+++ b/artemis-core-client/src/main/java/org/apache/activemq/artemis/core/client/impl/ClientSessionImpl.java
@@ -239,14 +239,14 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
 
    @Override
    public void createQueue(final SimpleString address, final SimpleString queueName) throws
ActiveMQException {
-      createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName);
+      createQueue(address, queueName, false);
    }
 
    @Override
    public void createQueue(final SimpleString address,
                            final SimpleString queueName,
                            final boolean durable) throws ActiveMQException {
-      createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName,
durable);
+      createQueue(address, queueName, null, durable, false);
    }
 
    @Override
@@ -260,7 +260,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
    public void createSharedQueue(SimpleString address,
                                  SimpleString queueName,
                                  boolean durable) throws ActiveMQException {
-      createSharedQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName,
null, durable);
+      createSharedQueue(address, queueName, null, durable);
    }
 
    @Override
@@ -295,8 +295,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
                            final SimpleString queueName,
                            final SimpleString filterString,
                            final boolean durable) throws ActiveMQException {
-      createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName,
filterString,
-                  durable);
+      createQueue(address, queueName, filterString, durable, false);
    }
 
    @Override
@@ -316,9 +315,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
                            final SimpleString filterString,
                            final boolean durable,
                            final boolean autoCreated) throws ActiveMQException {
-      createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName,
filterString,
-                  durable,
-                  autoCreated);
+      createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName,
filterString, durable, autoCreated);
    }
 
    @Override
@@ -332,7 +329,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
 
    @Override
    public void createTemporaryQueue(final SimpleString address, final SimpleString queueName)
throws ActiveMQException {
-      createTemporaryQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(),
queueName);
+      createTemporaryQueue(address, queueName, null);
    }
 
    @Override
@@ -351,7 +348,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
    public void createTemporaryQueue(final String address,
                                     final String queueName,
                                     final String filter) throws ActiveMQException {
-      createTemporaryQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(),
queueName, filter);
+      createTemporaryQueue(SimpleString.toSimpleString(address), SimpleString.toSimpleString(queueName),
SimpleString.toSimpleString(filter));
    }
 
 
@@ -416,14 +413,7 @@ public final class ClientSessionImpl implements ClientSessionInternal,
FailureLi
    public void createTemporaryQueue(final SimpleString address,
                                     final RoutingType routingType,
                                     final SimpleString queueName) throws ActiveMQException
{
-      internalCreateQueue(address,
-                          queueName, routingType,
-                          null,
-                          false,
-                          true,
-                          ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
-                          ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(),
-                          false);
+      createTemporaryQueue(address, routingType, queueName, null);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java
index 3e9bb4c..d87fba3 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/config/impl/Validators.java
@@ -170,6 +170,17 @@ public final class Validators {
       public void validate(final String name, final Object value) {
          String val = (String) value;
          if (val == null || !val.equals(RoutingType.ANYCAST.toString()) &&
+            !val.equals(RoutingType.MULTICAST.toString())) {
+            throw ActiveMQMessageBundle.BUNDLE.invalidRoutingType(val);
+         }
+      }
+   };
+
+   public static final Validator DIVERT_ROUTING_TYPE = new Validator() {
+      @Override
+      public void validate(final String name, final Object value) {
+         String val = (String) value;
+         if (val == null || !val.equals(RoutingType.ANYCAST.toString()) &&
             !val.equals(RoutingType.MULTICAST.toString()) &&
             !val.equals(RoutingType.PASS.toString()) &&
             !val.equals(RoutingType.STRIP.toString())) {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/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 171a07f..05f953b 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
@@ -183,6 +183,14 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
    private static final String AUTO_DELETE_ADDRESSES = "auto-delete-addresses";
 
+   private static final String DEFAULT_DELETE_ON_NO_CONSUMERS = "default-delete-on-no-consumers";
+
+   private static final String DEFAULT_MAX_CONSUMERS = "default-max-consumers";
+
+   private static final String DEFAULT_QUEUE_ROUTING_TYPE = "default-queue-routing-type";
+
+   private static final String DEFAULT_ADDRESS_ROUTING_TYPE = "default-address-routing-type";
+
    private static final String MANAGEMENT_BROWSE_PAGE_SIZE = "management-browse-page-size";
 
    private static final String MAX_CONNECTIONS_NODE_NAME = "max-connections";
@@ -871,6 +879,20 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
             addressSettings.setAutoDeleteAddresses(XMLUtil.parseBoolean(child));
          } else if (MANAGEMENT_BROWSE_PAGE_SIZE.equalsIgnoreCase(name)) {
             addressSettings.setManagementBrowsePageSize(XMLUtil.parseInt(child));
+         } else if (DEFAULT_DELETE_ON_NO_CONSUMERS.equalsIgnoreCase(name)) {
+            addressSettings.setDefaultDeleteOnNoConsumers(XMLUtil.parseBoolean(child));
+         } else if (DEFAULT_MAX_CONSUMERS.equalsIgnoreCase(name)) {
+            addressSettings.setDefaultMaxConsumers(XMLUtil.parseInt(child));
+         } else if (DEFAULT_QUEUE_ROUTING_TYPE.equalsIgnoreCase(name)) {
+            String value = getTrimmedTextContent(child);
+            Validators.ROUTING_TYPE.validate(DEFAULT_QUEUE_ROUTING_TYPE, value);
+            RoutingType routingType = RoutingType.valueOf(value);
+            addressSettings.setDefaultQueueRoutingType(routingType);
+         } else if (DEFAULT_ADDRESS_ROUTING_TYPE.equalsIgnoreCase(name)) {
+            String value = getTrimmedTextContent(child);
+            Validators.ROUTING_TYPE.validate(DEFAULT_ADDRESS_ROUTING_TYPE, value);
+            RoutingType routingType = RoutingType.valueOf(value);
+            addressSettings.setDefaultAddressRoutingType(routingType);
          }
       }
       return setting;
@@ -1570,7 +1592,7 @@ public final class FileConfigurationParser extends XMLConfigurationUtil
{
 
       String transformerClassName = getString(e, "transformer-class-name", null, Validators.NO_CHECK);
 
-      RoutingType routingType = RoutingType.valueOf(getString(e, "routing-type", ActiveMQDefaultConfiguration.getDefaultDivertRoutingType(),
Validators.ROUTING_TYPE));
+      RoutingType routingType = RoutingType.valueOf(getString(e, "routing-type", ActiveMQDefaultConfiguration.getDefaultDivertRoutingType(),
Validators.DIVERT_ROUTING_TYPE));
 
       String filterString = null;
 

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
index a43f28d..ef8b9a8 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/management/impl/ActiveMQServerControlImpl.java
@@ -619,14 +619,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements
Active
    @Deprecated
    @Override
    public void deployQueue(final String address, final String name, final String filterString)
throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         server.deployQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(),
new SimpleString(name), new SimpleString(filterString), true, false);
-      } finally {
-         blockOnIO();
-      }
+      deployQueue(address, name, filterString, true);
    }
 
    @Deprecated
@@ -640,7 +633,7 @@ public class ActiveMQServerControlImpl extends AbstractControl implements
Active
       SimpleString filter = filterStr == null ? null : new SimpleString(filterStr);
       clearIO();
       try {
-         server.deployQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(),
new SimpleString(name), filter, durable, false);
+         server.deployQueue(SimpleString.toSimpleString(address), server.getAddressSettingsRepository().getMatch(address).getDefaultQueueRoutingType(),
new SimpleString(name), filter, durable, false);
       } finally {
          blockOnIO();
       }
@@ -648,92 +641,34 @@ public class ActiveMQServerControlImpl extends AbstractControl implements
Active
 
    @Override
    public void createQueue(final String address, final String name) throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         server.createQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(),
new SimpleString(name), null, true, false);
-      } finally {
-         blockOnIO();
-      }
+      createQueue(address, name, true);
    }
 
    @Override
    public void createQueue(final String address, final String name, final String routingType)
throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         server.createQueue(SimpleString.toSimpleString(address), RoutingType.valueOf(routingType.toUpperCase()),
new SimpleString(name), null, true, false);
-      } finally {
-         blockOnIO();
-      }
+      createQueue(address, name, routingType, true);
    }
 
    @Override
    public void createQueue(final String address, final String name, final boolean durable)
throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         server.createQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(),
new SimpleString(name), null, durable, false);
-      } finally {
-         blockOnIO();
-      }
+      createQueue(address, name, null, durable);
    }
 
    @Override
    public void createQueue(final String address, final String name, final boolean durable,
final String routingType) throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         server.createQueue(SimpleString.toSimpleString(address), RoutingType.valueOf(routingType.toUpperCase()),
new SimpleString(name), null, durable, false);
-      } finally {
-         blockOnIO();
-      }
+      createQueue(address, name, null, durable, routingType);
    }
 
    @Override
-   public void createQueue(final String address,
-                           final String name,
-                           final String filterStr,
-                           final boolean durable) throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         SimpleString filter = null;
-         if (filterStr != null && !filterStr.trim().equals("")) {
-            filter = new SimpleString(filterStr);
-         }
-
-         server.createQueue(SimpleString.toSimpleString(address), ActiveMQDefaultConfiguration.getDefaultRoutingType(),
new SimpleString(name), filter, durable, false);
-      } finally {
-         blockOnIO();
-      }
+   public void createQueue(final String address, final String name, final String filterStr,
final boolean durable) throws Exception {
+      createQueue(address, name, filterStr, durable, server.getAddressSettingsRepository().getMatch(address).getDefaultQueueRoutingType().toString());
    }
 
 
    @Override
-   public void createQueue(final String address,
-                           final String name,
-                           final String filterStr,
-                           final boolean durable,
-                           final String routingType) throws Exception {
-      checkStarted();
-
-      clearIO();
-      try {
-         SimpleString filter = null;
-         if (filterStr != null && !filterStr.trim().equals("")) {
-            filter = new SimpleString(filterStr);
-         }
-
-         server.createQueue(SimpleString.toSimpleString(address), RoutingType.valueOf(routingType.toUpperCase()),
new SimpleString(name), filter, durable, false);
-      } finally {
-         blockOnIO();
-      }
+   public void createQueue(final String address, final String name, final String filterStr,
final boolean durable, final String routingType) throws Exception {
+      AddressSettings addressSettings = server.getAddressSettingsRepository().getMatch(address);
+      createQueue(address, routingType, name, filterStr, durable, addressSettings.getDefaultMaxConsumers(),
addressSettings.isDefaultDeleteOnNoConsumers(), addressSettings.isAutoCreateAddresses());
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/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 98c2304..237e750 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
@@ -1500,7 +1500,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      return createQueue(address, routingType, queueName, filterString, null, durable, temporary,
getAddressSettingsRepository().getMatch(address.toString()).getDefaultMaxConsumers(), getAddressSettingsRepository().getMatch(address.toString()).isDefaultDeleteOnNoConsumers(),
true);
+      AddressSettings as = getAddressSettingsRepository().getMatch(address.toString());
+      return createQueue(address, routingType, queueName, filterString, null, durable, temporary,
as.getDefaultMaxConsumers(), as.isDefaultDeleteOnNoConsumers(), as.isAutoCreateAddresses());
    }
 
    @Override
@@ -1509,7 +1510,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      return createQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), queueName,
filterString, durable, temporary);
+      return createQueue(address, getAddressSettingsRepository().getMatch(address.toString()).getDefaultQueueRoutingType(),
queueName, filterString, durable, temporary);
    }
 
    @Override
@@ -1533,7 +1534,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString user,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      return createQueue(address, routingType, queueName, filterString, user, durable, temporary,
getAddressSettingsRepository().getMatch(address.toString()).getDefaultMaxConsumers(), getAddressSettingsRepository().getMatch(address.toString()).isDefaultDeleteOnNoConsumers(),
true);
+      AddressSettings as = getAddressSettingsRepository().getMatch(address.toString());
+      return createQueue(address, routingType, queueName, filterString, user, durable, temporary,
as.getDefaultMaxConsumers(), as.isDefaultDeleteOnNoConsumers(), as.isAutoCreateAddresses());
    }
 
    @Override
@@ -1556,9 +1558,10 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final boolean durable,
                             final boolean temporary,
                             final boolean autoCreated) throws Exception {
+      AddressSettings as = getAddressSettingsRepository().getMatch(address.toString());
       return createQueue(address, routingType, queueName, filterString, user, durable, temporary,
-                         getAddressSettingsRepository().getMatch(address.toString()).getDefaultMaxConsumers(),
-                         getAddressSettingsRepository().getMatch(address.toString()).isDefaultDeleteOnNoConsumers(),
autoCreated);
+                         as.getDefaultMaxConsumers(),
+                         as.isDefaultDeleteOnNoConsumers(), autoCreated);
    }
 
    @Override
@@ -1587,7 +1590,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
 
       if (routingType == null) {
          AddressInfo addressInfo = getAddressInfo(address);
-         routingType = addressInfo.getRoutingTypes().size() == 1 ? addressInfo.getRoutingType()
: ActiveMQDefaultConfiguration.getDefaultRoutingType();
+         routingType = addressInfo.getRoutingTypes().size() == 1 ? addressInfo.getRoutingType()
: getAddressSettingsRepository().getMatch(address.toString()).getDefaultQueueRoutingType();
          if (routingType == null) {
             // TODO (mtaylor) throw exception Can not determine routing type info from address
          }
@@ -1644,7 +1647,7 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final SimpleString filterString,
                             final boolean durable,
                             final boolean temporary) throws Exception {
-      return deployQueue(address, ActiveMQDefaultConfiguration.getDefaultRoutingType(), resourceName,
filterString, durable, temporary, false);
+      return deployQueue(address, getAddressSettingsRepository().getMatch(address.toString()).getDefaultQueueRoutingType(),
resourceName, filterString, durable, temporary);
    }
 
    @Override
@@ -1674,7 +1677,8 @@ public class ActiveMQServerImpl implements ActiveMQServer {
                             final boolean durable,
                             final boolean temporary,
                             final boolean autoCreated) throws Exception {
-      return deployQueue(address, routingType, queueName, filterString, durable, temporary,
autoCreated, getAddressSettingsRepository().getMatch(address.toString()).getDefaultMaxConsumers(),
getAddressSettingsRepository().getMatch(address.toString()).isDefaultDeleteOnNoConsumers(),
true);
+      AddressSettings as = getAddressSettingsRepository().getMatch(address.toString());
+      return deployQueue(address, routingType, queueName, filterString, durable, temporary,
autoCreated, as.getDefaultMaxConsumers(), as.isDefaultDeleteOnNoConsumers(), as.isAutoCreateAddresses());
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
index 4d0985b..118203e 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/impl/ServerSessionImpl.java
@@ -31,7 +31,6 @@ import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.atomic.AtomicLong;
 
-import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.ActiveMQException;
 import org.apache.activemq.artemis.api.core.ActiveMQIOErrorException;
 import org.apache.activemq.artemis.api.core.ActiveMQIllegalStateException;
@@ -79,6 +78,7 @@ import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.TempQueueObserver;
 import org.apache.activemq.artemis.core.server.management.ManagementService;
 import org.apache.activemq.artemis.core.server.management.Notification;
+import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.core.transaction.ResourceManager;
 import org.apache.activemq.artemis.core.transaction.Transaction;
 import org.apache.activemq.artemis.core.transaction.Transaction.State;
@@ -503,7 +503,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener
{
                             final SimpleString filterString,
                             final boolean temporary,
                             final boolean durable) throws Exception {
-      return createQueue(address, name, ActiveMQDefaultConfiguration.getDefaultRoutingType(),
filterString, temporary, durable, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), false);
+      AddressSettings as = server.getAddressSettingsRepository().getMatch(address.toString());
+      return createQueue(address, name, as.getDefaultQueueRoutingType(), filterString, temporary,
durable, as.getDefaultMaxConsumers(), as.isDefaultDeleteOnNoConsumers(), false);
    }
 
    @Override
@@ -513,7 +514,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener
{
                             final SimpleString filterString,
                             final boolean temporary,
                             final boolean durable) throws Exception {
-      return createQueue(address, name, routingType, filterString, temporary, durable, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), false);
+      AddressSettings as = server.getAddressSettingsRepository().getMatch(address.toString());
+      return createQueue(address, name, routingType, filterString, temporary, durable, as.getDefaultMaxConsumers(),
as.isDefaultDeleteOnNoConsumers(), false);
    }
 
    @Override
@@ -576,7 +578,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener
{
                             boolean temporary,
                             boolean durable,
                             boolean autoCreated) throws Exception {
-      return createQueue(address, name, routingType, filterString, temporary, durable, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(),
ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), autoCreated);
+      AddressSettings as = server.getAddressSettingsRepository().getMatch(address.toString());
+      return createQueue(address, name, routingType, filterString, temporary, durable, as.getDefaultMaxConsumers(),
as.isDefaultDeleteOnNoConsumers(), autoCreated);
    }
 
    @Override

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
index 5d65e05..52cc165 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/settings/impl/AddressSettings.java
@@ -22,8 +22,10 @@ import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
 import org.apache.activemq.artemis.api.core.ActiveMQBuffer;
 import org.apache.activemq.artemis.api.core.SimpleString;
 import org.apache.activemq.artemis.core.journal.EncodingSupport;
+import org.apache.activemq.artemis.core.server.RoutingType;
 import org.apache.activemq.artemis.core.settings.Mergeable;
 import org.apache.activemq.artemis.utils.BufferHelper;
+import org.apache.activemq.artemis.utils.DataConstants;
 
 /**
  * Configuration settings that are applied on the address level
@@ -158,6 +160,10 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
 
    private Boolean defaultDeleteOnNoConsumers = null;
 
+   private RoutingType defaultQueueRoutingType = null;
+
+   private RoutingType defaultAddressRoutingType = null;
+
    //from amq5
    //make it transient
    private transient Integer queuePrefetch = null;
@@ -195,6 +201,8 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
       this.maxSizeBytesRejectThreshold = other.maxSizeBytesRejectThreshold;
       this.defaultMaxConsumers = other.defaultMaxConsumers;
       this.defaultDeleteOnNoConsumers = other.defaultDeleteOnNoConsumers;
+      this.defaultQueueRoutingType = other.defaultQueueRoutingType;
+      this.defaultAddressRoutingType = other.defaultAddressRoutingType;
    }
 
    public AddressSettings() {
@@ -298,6 +306,24 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
       return this;
    }
 
+   public RoutingType getDefaultQueueRoutingType() {
+      return defaultQueueRoutingType != null ? defaultQueueRoutingType : ActiveMQDefaultConfiguration.getDefaultRoutingType();
+   }
+
+   public AddressSettings setDefaultQueueRoutingType(RoutingType defaultQueueRoutingType)
{
+      this.defaultQueueRoutingType = defaultQueueRoutingType;
+      return this;
+   }
+
+   public RoutingType getDefaultAddressRoutingType() {
+      return defaultAddressRoutingType != null ? defaultAddressRoutingType : ActiveMQDefaultConfiguration.getDefaultRoutingType();
+   }
+
+   public AddressSettings setDefaultAddressRoutingType(RoutingType defaultAddressRoutingType)
{
+      this.defaultAddressRoutingType = defaultAddressRoutingType;
+      return this;
+   }
+
    public boolean isLastValueQueue() {
       return lastValueQueue != null ? lastValueQueue : AddressSettings.DEFAULT_LAST_VALUE_QUEUE;
    }
@@ -589,6 +615,12 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
       if (defaultDeleteOnNoConsumers == null) {
          defaultDeleteOnNoConsumers = merged.defaultDeleteOnNoConsumers;
       }
+      if (defaultQueueRoutingType == null) {
+         defaultQueueRoutingType = merged.defaultQueueRoutingType;
+      }
+      if (defaultAddressRoutingType == null) {
+         defaultAddressRoutingType = merged.defaultAddressRoutingType;
+      }
    }
 
    @Override
@@ -666,6 +698,10 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
       defaultMaxConsumers = BufferHelper.readNullableInteger(buffer);
 
       defaultDeleteOnNoConsumers = BufferHelper.readNullableBoolean(buffer);
+
+      defaultQueueRoutingType = RoutingType.getType(buffer.readByte());
+
+      defaultAddressRoutingType = RoutingType.getType(buffer.readByte());
    }
 
    @Override
@@ -701,7 +737,9 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
          BufferHelper.sizeOfNullableInteger(managementBrowsePageSize) +
          BufferHelper.sizeOfNullableLong(maxSizeBytesRejectThreshold) +
          BufferHelper.sizeOfNullableInteger(defaultMaxConsumers) +
-         BufferHelper.sizeOfNullableBoolean(defaultDeleteOnNoConsumers);
+         BufferHelper.sizeOfNullableBoolean(defaultDeleteOnNoConsumers) +
+         DataConstants.SIZE_BYTE +
+         DataConstants.SIZE_BYTE;
    }
 
    @Override
@@ -767,6 +805,10 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
       BufferHelper.writeNullableInteger(buffer, defaultMaxConsumers);
 
       BufferHelper.writeNullableBoolean(buffer, defaultDeleteOnNoConsumers);
+
+      buffer.writeByte(defaultQueueRoutingType == null ? -1 : defaultQueueRoutingType.getType());
+
+      buffer.writeByte(defaultAddressRoutingType == null ? -1 : defaultAddressRoutingType.getType());
    }
 
    /* (non-Javadoc)
@@ -808,6 +850,8 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
       result = prime * result + ((maxSizeBytesRejectThreshold == null) ? 0 : maxSizeBytesRejectThreshold.hashCode());
       result = prime * result + ((defaultMaxConsumers == null) ? 0 : defaultMaxConsumers.hashCode());
       result = prime * result + ((defaultDeleteOnNoConsumers == null) ? 0 : defaultDeleteOnNoConsumers.hashCode());
+      result = prime * result + ((defaultQueueRoutingType == null) ? 0 : defaultQueueRoutingType.hashCode());
+      result = prime * result + ((defaultAddressRoutingType == null) ? 0 : defaultAddressRoutingType.hashCode());
       return result;
    }
 
@@ -986,6 +1030,18 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
             return false;
       } else if (!defaultDeleteOnNoConsumers.equals(other.defaultDeleteOnNoConsumers))
          return false;
+
+      if (defaultQueueRoutingType == null) {
+         if (other.defaultQueueRoutingType != null)
+            return false;
+      } else if (!defaultQueueRoutingType.equals(other.defaultQueueRoutingType))
+         return false;
+
+      if (defaultAddressRoutingType == null) {
+         if (other.defaultAddressRoutingType != null)
+            return false;
+      } else if (!defaultAddressRoutingType.equals(other.defaultAddressRoutingType))
+         return false;
       return true;
    }
 
@@ -1055,6 +1111,10 @@ public class AddressSettings implements Mergeable<AddressSettings>,
Serializable
          defaultMaxConsumers +
          ", defaultDeleteOnNoConsumers=" +
          defaultDeleteOnNoConsumers +
+         ", defaultQueueRoutingType=" +
+         defaultQueueRoutingType +
+         ", defaultAddressRoutingType=" +
+         defaultAddressRoutingType +
          "]";
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/main/resources/schema/artemis-configuration.xsd
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/resources/schema/artemis-configuration.xsd b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
index 6cbe377..bacf702 100644
--- a/artemis-server/src/main/resources/schema/artemis-configuration.xsd
+++ b/artemis-server/src/main/resources/schema/artemis-configuration.xsd
@@ -1577,20 +1577,12 @@
 
          <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>
 
-         <xsd:element name="routing-type" default="STRIP" maxOccurs="1" minOccurs="0">
+         <xsd:element name="routing-type" type="divert-routing-type" default="STRIP" maxOccurs="1"
minOccurs="0">
             <xsd:annotation>
                <xsd:documentation>
                   how should the routing-type on the diverted messages be set?
                </xsd:documentation>
             </xsd:annotation>
-            <xsd:simpleType>
-               <xsd:restriction base="xsd:string">
-                  <xsd:enumeration value="ANYCAST"/>
-                  <xsd:enumeration value="MULTICAST"/>
-                  <xsd:enumeration value="STRIP"/>
-                  <xsd:enumeration value="PASS"/>
-               </xsd:restriction>
-            </xsd:simpleType>
          </xsd:element>
       </xsd:all>
 
@@ -2489,8 +2481,7 @@
                </xsd:annotation>
             </xsd:element>
 
-            <xsd:element name="management-browse-page-size" type="xsd:int" default="200"
maxOccurs="1"
-                         minOccurs="0">
+            <xsd:element name="management-browse-page-size" type="xsd:int" default="200"
maxOccurs="1" minOccurs="0">
                <xsd:annotation>
                   <xsd:documentation>
                      how many message a management resource can browse
@@ -2498,6 +2489,38 @@
                </xsd:annotation>
             </xsd:element>
 
+            <xsd:element name="default-delete-on-no-consumers" type="xsd:boolean" default="false"
maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     Purge and pause this queue when the last consumer disconnects
+                  </xsd:documentation>
+               </xsd:annotation>
+            </xsd:element>
+
+            <xsd:element name="default-max-consumers" type="xsd:int" default="200" maxOccurs="1"
minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     the maximum number of consumers allowed on this queue at any one time
+                  </xsd:documentation>
+               </xsd:annotation>
+            </xsd:element>
+
+            <xsd:element name="default-queue-routing-type" type="routing-type" default="MULTICAST"
maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     the routing-type used on auto-created queues
+                  </xsd:documentation>
+               </xsd:annotation>
+            </xsd:element>
+
+            <xsd:element name="default-address-routing-type" type="routing-type" default="MULTICAST"
maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     the routing-type used on auto-created addresses
+                  </xsd:documentation>
+               </xsd:annotation>
+            </xsd:element>
+
          </xsd:all>
 
          <xsd:attribute name="match" type="xsd:string" use="required">
@@ -2594,6 +2617,22 @@
 
    <!-- 2.0 Addressing configuration -->
 
+   <xsd:simpleType name="routing-type">
+      <xsd:restriction base="xsd:string">
+         <xsd:enumeration value="ANYCAST"/>
+         <xsd:enumeration value="MULTICAST"/>
+      </xsd:restriction>
+   </xsd:simpleType>
+
+   <xsd:simpleType name="divert-routing-type">
+      <xsd:restriction base="xsd:string">
+         <xsd:enumeration value="ANYCAST"/>
+         <xsd:enumeration value="MULTICAST"/>
+         <xsd:enumeration value="STRIP"/>
+         <xsd:enumeration value="PASS"/>
+      </xsd:restriction>
+   </xsd:simpleType>
+
    <xsd:complexType name="queueType">
       <xsd:all>
          <xsd:element ref="filter" maxOccurs="1" minOccurs="0"/>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
index 533e65d..7f0d8c1 100644
--- a/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
+++ b/artemis-server/src/test/java/org/apache/activemq/artemis/core/config/impl/FileConfigurationTest.java
@@ -305,6 +305,10 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       assertEquals(true, conf.getAddressesSettings().get("a1").isAutoDeleteJmsQueues());
       assertEquals(true, conf.getAddressesSettings().get("a1").isAutoCreateJmsTopics());
       assertEquals(true, conf.getAddressesSettings().get("a1").isAutoDeleteJmsTopics());
+      assertEquals(false, conf.getAddressesSettings().get("a1").isDefaultDeleteOnNoConsumers());
+      assertEquals(5, conf.getAddressesSettings().get("a1").getDefaultMaxConsumers());
+      assertEquals(RoutingType.ANYCAST, conf.getAddressesSettings().get("a1").getDefaultQueueRoutingType());
+      assertEquals(RoutingType.MULTICAST, conf.getAddressesSettings().get("a1").getDefaultAddressRoutingType());
 
       assertEquals("a2.1", conf.getAddressesSettings().get("a2").getDeadLetterAddress().toString());
       assertEquals("a2.2", conf.getAddressesSettings().get("a2").getExpiryAddress().toString());
@@ -320,6 +324,10 @@ public class FileConfigurationTest extends ConfigurationImplTest {
       assertEquals(false, conf.getAddressesSettings().get("a2").isAutoDeleteJmsQueues());
       assertEquals(false, conf.getAddressesSettings().get("a2").isAutoCreateJmsTopics());
       assertEquals(false, conf.getAddressesSettings().get("a2").isAutoDeleteJmsTopics());
+      assertEquals(true, conf.getAddressesSettings().get("a2").isDefaultDeleteOnNoConsumers());
+      assertEquals(15, conf.getAddressesSettings().get("a2").getDefaultMaxConsumers());
+      assertEquals(RoutingType.MULTICAST, conf.getAddressesSettings().get("a2").getDefaultQueueRoutingType());
+      assertEquals(RoutingType.ANYCAST, conf.getAddressesSettings().get("a2").getDefaultAddressRoutingType());
 
       assertTrue(conf.getResourceLimitSettings().containsKey("myUser"));
       assertEquals(104, conf.getResourceLimitSettings().get("myUser").getMaxConnections());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/4a53f9b6/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
index 9cfcb56..c493198 100644
--- a/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/artemis-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -272,6 +272,10 @@
             <auto-delete-queues>true</auto-delete-queues>
             <auto-create-addresses>true</auto-create-addresses>
             <auto-delete-addresses>true</auto-delete-addresses>
+            <default-delete-on-no-consumers>false</default-delete-on-no-consumers>
+            <default-max-consumers>5</default-max-consumers>
+            <default-queue-routing-type>ANYCAST</default-queue-routing-type>
+            <default-address-routing-type>MULTICAST</default-address-routing-type>
          </address-setting>
          <address-setting match="a2">
             <dead-letter-address>a2.1</dead-letter-address>
@@ -292,6 +296,10 @@
             <auto-delete-queues>false</auto-delete-queues>
             <auto-create-addresses>false</auto-create-addresses>
             <auto-delete-addresses>false</auto-delete-addresses>
+            <default-delete-on-no-consumers>true</default-delete-on-no-consumers>
+            <default-max-consumers>15</default-max-consumers>
+            <default-queue-routing-type>MULTICAST</default-queue-routing-type>
+            <default-address-routing-type>ANYCAST</default-address-routing-type>
          </address-setting>
       </address-settings>
       <resource-limit-settings>


Mime
View raw message