activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/4] activemq-6 git commit: ACTIVEMQ6-13 auto-create/auto-delete jms queues
Date Tue, 13 Jan 2015 21:40:52 GMT
http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/main/java/org/apache/activemq/core/server/impl/ServerSessionImpl.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/server/impl/ServerSessionImpl.java b/activemq-server/src/main/java/org/apache/activemq/core/server/impl/ServerSessionImpl.java
index 553747b..3790795 100644
--- a/activemq-server/src/main/java/org/apache/activemq/core/server/impl/ServerSessionImpl.java
+++ b/activemq-server/src/main/java/org/apache/activemq/core/server/impl/ServerSessionImpl.java
@@ -37,6 +37,7 @@ import org.apache.activemq.api.core.Pair;
 import org.apache.activemq.api.core.SimpleString;
 import org.apache.activemq.api.core.management.CoreNotificationType;
 import org.apache.activemq.api.core.management.ManagementHelper;
+import org.apache.activemq.api.core.management.ResourceNames;
 import org.apache.activemq.core.client.impl.ClientMessageImpl;
 import org.apache.activemq.core.exception.ActiveMQXAException;
 import org.apache.activemq.core.filter.Filter;
@@ -549,7 +550,15 @@ public class ServerSessionImpl implements ServerSession, FailureListener
          securityStore.check(address, CheckType.CREATE_NON_DURABLE_QUEUE, this);
       }
 
-      Queue queue = server.createQueue(address, name, filterString, durable, temporary);
+      // any non-temporary JMS queue created via this method should be marked as auto-created
+      if (!temporary && address.toString().startsWith(ResourceNames.JMS_QUEUE) && address.equals(name))
+      {
+         server.createQueue(address, name, filterString, durable, temporary, true);
+      }
+      else
+      {
+         server.createQueue(address, name, filterString, durable, temporary);
+      }
 
       if (temporary)
       {
@@ -676,6 +685,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener
 
    public QueueQueryResult executeQueueQuery(final SimpleString name) throws Exception
    {
+      boolean autoCreateJmsQueues = name.toString().startsWith(ResourceNames.JMS_QUEUE) && server.getAddressSettingsRepository().getMatch(name.toString()).isAutoCreateJmsQueues();
+
       if (name == null)
       {
          throw ActiveMQMessageBundle.BUNDLE.queueNameIsNull();
@@ -699,16 +710,21 @@ public class ServerSessionImpl implements ServerSession, FailureListener
                                          queue.isTemporary(),
                                          filterString,
                                          queue.getConsumerCount(),
-                                         queue.getMessageCount());
+                                         queue.getMessageCount(),
+                                         autoCreateJmsQueues);
       }
       // make an exception for the management address (see HORNETQ-29)
       else if (name.equals(managementAddress))
       {
-         response = new QueueQueryResult(name, managementAddress, true, false, null, -1, -1);
+         response = new QueueQueryResult(name, managementAddress, true, false, null, -1, -1, autoCreateJmsQueues);
+      }
+      else if (autoCreateJmsQueues)
+      {
+         response = new QueueQueryResult(name, name, true, false, null, 0, 0, true, false);
       }
       else
       {
-         response = new QueueQueryResult();
+         response = new QueueQueryResult(null, null, false, false, null, 0, 0, false, false);
       }
 
       return response;
@@ -716,6 +732,8 @@ public class ServerSessionImpl implements ServerSession, FailureListener
 
    public BindingQueryResult executeBindingQuery(final SimpleString address) throws Exception
    {
+      boolean autoCreateJmsQueues = address.toString().startsWith(ResourceNames.JMS_QUEUE) && server.getAddressSettingsRepository().getMatch(address.toString()).isAutoCreateJmsQueues();
+
       if (address == null)
       {
          throw ActiveMQMessageBundle.BUNDLE.addressIsNull();
@@ -726,7 +744,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener
       // make an exception for the management address (see HORNETQ-29)
       if (address.equals(managementAddress))
       {
-         return new BindingQueryResult(true, names);
+         return new BindingQueryResult(true, names, autoCreateJmsQueues);
       }
 
       Bindings bindings = postOffice.getMatchingBindings(address);
@@ -739,7 +757,7 @@ public class ServerSessionImpl implements ServerSession, FailureListener
          }
       }
 
-      return new BindingQueryResult(!names.isEmpty(), names);
+      return new BindingQueryResult(!names.isEmpty(), names, autoCreateJmsQueues);
    }
 
    public void forceConsumerDelivery(final long consumerID, final long sequence) throws Exception

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/main/java/org/apache/activemq/core/settings/impl/AddressSettings.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/java/org/apache/activemq/core/settings/impl/AddressSettings.java b/activemq-server/src/main/java/org/apache/activemq/core/settings/impl/AddressSettings.java
index 0d3a32e..5a8689b 100644
--- a/activemq-server/src/main/java/org/apache/activemq/core/settings/impl/AddressSettings.java
+++ b/activemq-server/src/main/java/org/apache/activemq/core/settings/impl/AddressSettings.java
@@ -56,6 +56,10 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
 
    public static final boolean DEFAULT_LAST_VALUE_QUEUE = false;
 
+   public static final boolean DEFAULT_AUTO_CREATE_QUEUES = true;
+
+   public static final boolean DEFAULT_AUTO_DELETE_QUEUES = true;
+
    public static final long DEFAULT_REDISTRIBUTION_DELAY = -1;
 
    public static final long DEFAULT_EXPIRY_DELAY = -1;
@@ -106,6 +110,10 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
 
    private SlowConsumerPolicy slowConsumerPolicy = null;
 
+   private Boolean autoCreateJmsQueues = null;
+
+   private Boolean autoDeleteJmsQueues = null;
+
    public AddressSettings(AddressSettings other)
    {
       this.addressFullMessagePolicy = other.addressFullMessagePolicy;
@@ -127,6 +135,8 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       this.slowConsumerThreshold = other.slowConsumerThreshold;
       this.slowConsumerCheckPeriod = other.slowConsumerCheckPeriod;
       this.slowConsumerPolicy = other.slowConsumerPolicy;
+      this.autoCreateJmsQueues = other.autoCreateJmsQueues;
+      this.autoDeleteJmsQueues = other.autoDeleteJmsQueues;
    }
 
    public AddressSettings()
@@ -134,6 +144,26 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
    }
 
 
+   public boolean isAutoCreateJmsQueues()
+   {
+      return autoCreateJmsQueues != null ? autoCreateJmsQueues : AddressSettings.DEFAULT_AUTO_CREATE_QUEUES;
+   }
+
+   public void setAutoCreateJmsQueues(final boolean autoCreateJmsQueues)
+   {
+      this.autoCreateJmsQueues = autoCreateJmsQueues;
+   }
+
+   public boolean isAutoDeleteJmsQueues()
+   {
+      return autoDeleteJmsQueues != null ? autoDeleteJmsQueues : AddressSettings.DEFAULT_AUTO_DELETE_QUEUES;
+   }
+
+   public void setAutoDeleteJmsQueues(final boolean autoDeleteJmsQueues)
+   {
+      this.autoDeleteJmsQueues = autoDeleteJmsQueues;
+   }
+
    public boolean isLastValueQueue()
    {
       return lastValueQueue != null ? lastValueQueue : AddressSettings.DEFAULT_LAST_VALUE_QUEUE;
@@ -398,6 +428,14 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       {
          slowConsumerPolicy = merged.slowConsumerPolicy;
       }
+      if (autoCreateJmsQueues == null)
+      {
+         autoCreateJmsQueues = merged.autoCreateJmsQueues;
+      }
+      if (autoDeleteJmsQueues == null)
+      {
+         autoDeleteJmsQueues = merged.autoDeleteJmsQueues;
+      }
    }
 
    @Override
@@ -458,6 +496,10 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       {
          slowConsumerPolicy = null;
       }
+
+      autoCreateJmsQueues = BufferHelper.readNullableBoolean(buffer);
+
+      autoDeleteJmsQueues = BufferHelper.readNullableBoolean(buffer);
    }
 
    @Override
@@ -482,7 +524,9 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
          BufferHelper.sizeOfNullableBoolean(sendToDLAOnNoRoute) +
          BufferHelper.sizeOfNullableLong(slowConsumerCheckPeriod) +
          BufferHelper.sizeOfNullableLong(slowConsumerThreshold) +
-         BufferHelper.sizeOfNullableSimpleString(slowConsumerPolicy != null ? slowConsumerPolicy.toString() : null);
+         BufferHelper.sizeOfNullableSimpleString(slowConsumerPolicy != null ? slowConsumerPolicy.toString() : null) +
+         BufferHelper.sizeOfNullableBoolean(autoCreateJmsQueues) +
+         BufferHelper.sizeOfNullableBoolean(autoDeleteJmsQueues);
    }
 
    @Override
@@ -526,6 +570,10 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       BufferHelper.writeNullableLong(buffer, slowConsumerCheckPeriod);
 
       buffer.writeNullableSimpleString(slowConsumerPolicy != null ? new SimpleString(slowConsumerPolicy.toString()) : null);
+
+      BufferHelper.writeNullableBoolean(buffer, autoCreateJmsQueues);
+
+      BufferHelper.writeNullableBoolean(buffer, autoDeleteJmsQueues);
    }
 
    /* (non-Javadoc)
@@ -556,6 +604,8 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       result = prime * result + ((slowConsumerThreshold == null) ? 0 : slowConsumerThreshold.hashCode());
       result = prime * result + ((slowConsumerCheckPeriod == null) ? 0 : slowConsumerCheckPeriod.hashCode());
       result = prime * result + ((slowConsumerPolicy == null) ? 0 : slowConsumerPolicy.hashCode());
+      result = prime * result + ((autoCreateJmsQueues == null) ? 0 : autoCreateJmsQueues.hashCode());
+      result = prime * result + ((autoDeleteJmsQueues == null) ? 0 : autoDeleteJmsQueues.hashCode());
       return result;
    }
 
@@ -705,6 +755,20 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
       }
       else if (!slowConsumerPolicy.equals(other.slowConsumerPolicy))
          return false;
+      if (autoCreateJmsQueues == null)
+      {
+         if (other.autoCreateJmsQueues != null)
+            return false;
+      }
+      else if (!autoCreateJmsQueues.equals(other.autoCreateJmsQueues))
+         return false;
+      if (autoDeleteJmsQueues == null)
+      {
+         if (other.autoDeleteJmsQueues != null)
+            return false;
+      }
+      else if (!autoDeleteJmsQueues.equals(other.autoDeleteJmsQueues))
+         return false;
       return true;
    }
 
@@ -751,6 +815,10 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
          slowConsumerCheckPeriod +
          ", slowConsumerPolicy=" +
          slowConsumerPolicy +
+         ", autoCreateJmsQueues=" +
+         autoCreateJmsQueues +
+         ", autoDeleteJmsQueues=" +
+         autoDeleteJmsQueues +
          "]";
    }
 }

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/main/resources/schema/activemq-configuration.xsd
----------------------------------------------------------------------
diff --git a/activemq-server/src/main/resources/schema/activemq-configuration.xsd b/activemq-server/src/main/resources/schema/activemq-configuration.xsd
index 7ca0468..bc6bea3 100644
--- a/activemq-server/src/main/resources/schema/activemq-configuration.xsd
+++ b/activemq-server/src/main/resources/schema/activemq-configuration.xsd
@@ -2258,6 +2258,23 @@
                   </xsd:documentation>
                </xsd:annotation>
             </xsd:element>
+
+            <xsd:element name="auto-create-jms-queues" type="xsd:boolean" default="true" maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     whether or not to automatically create JMS queues when a producer sends or a consumer connects to a
+                     queue
+                  </xsd:documentation>
+               </xsd:annotation>
+            </xsd:element>
+
+            <xsd:element name="auto-delete-jms-queues" type="xsd:boolean" default="true" maxOccurs="1" minOccurs="0">
+               <xsd:annotation>
+                  <xsd:documentation>
+                     whether or not to delete auto-created JMS queues when the queue has 0 consumers and 0 messages
+                  </xsd:documentation>
+               </xsd:annotation>
+            </xsd:element>
          </xsd:all>
 
          <xsd:attribute name="match" type="xsd:string" use="required">

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/test/java/org/apache/activemq/core/config/impl/FileConfigurationTest.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/test/java/org/apache/activemq/core/config/impl/FileConfigurationTest.java b/activemq-server/src/test/java/org/apache/activemq/core/config/impl/FileConfigurationTest.java
index a892c03..bf10266 100644
--- a/activemq-server/src/test/java/org/apache/activemq/core/config/impl/FileConfigurationTest.java
+++ b/activemq-server/src/test/java/org/apache/activemq/core/config/impl/FileConfigurationTest.java
@@ -297,6 +297,8 @@ public class FileConfigurationTest extends ConfigurationImplTest
       assertEquals(10, conf.getAddressesSettings().get("a1").getSlowConsumerThreshold());
       assertEquals(5, conf.getAddressesSettings().get("a1").getSlowConsumerCheckPeriod());
       assertEquals(SlowConsumerPolicy.NOTIFY, conf.getAddressesSettings().get("a1").getSlowConsumerPolicy());
+      assertEquals(true, conf.getAddressesSettings().get("a1").isAutoCreateJmsQueues());
+      assertEquals(true, conf.getAddressesSettings().get("a1").isAutoDeleteJmsQueues());
 
       assertEquals("a2.1", conf.getAddressesSettings().get("a2").getDeadLetterAddress().toString());
       assertEquals("a2.2", conf.getAddressesSettings().get("a2").getExpiryAddress().toString());
@@ -308,6 +310,8 @@ public class FileConfigurationTest extends ConfigurationImplTest
       assertEquals(20, conf.getAddressesSettings().get("a2").getSlowConsumerThreshold());
       assertEquals(15, conf.getAddressesSettings().get("a2").getSlowConsumerCheckPeriod());
       assertEquals(SlowConsumerPolicy.KILL, conf.getAddressesSettings().get("a2").getSlowConsumerPolicy());
+      assertEquals(false, conf.getAddressesSettings().get("a2").isAutoCreateJmsQueues());
+      assertEquals(false, conf.getAddressesSettings().get("a2").isAutoDeleteJmsQueues());
 
 
       assertEquals(2, conf.getQueueConfigurations().size());

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/test/java/org/apache/activemq/core/server/impl/ScheduledDeliveryHandlerTest.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/test/java/org/apache/activemq/core/server/impl/ScheduledDeliveryHandlerTest.java b/activemq-server/src/test/java/org/apache/activemq/core/server/impl/ScheduledDeliveryHandlerTest.java
index abb6e86..7b85924 100644
--- a/activemq-server/src/test/java/org/apache/activemq/core/server/impl/ScheduledDeliveryHandlerTest.java
+++ b/activemq-server/src/test/java/org/apache/activemq/core/server/impl/ScheduledDeliveryHandlerTest.java
@@ -42,7 +42,6 @@ import org.apache.activemq.core.message.BodyEncoder;
 import org.apache.activemq.core.paging.PagingStore;
 import org.apache.activemq.core.paging.cursor.PageSubscription;
 import org.apache.activemq.core.server.Consumer;
-import org.apache.activemq.core.server.ActiveMQServer;
 import org.apache.activemq.core.server.MessageReference;
 import org.apache.activemq.core.server.Queue;
 import org.apache.activemq.core.server.RoutingContext;
@@ -1054,6 +1053,12 @@ public class ScheduledDeliveryHandlerTest extends Assert
       }
 
       @Override
+      public boolean isAutoCreated()
+      {
+         return false;
+      }
+
+      @Override
       public void addConsumer(Consumer consumer) throws Exception
       {
 
@@ -1072,7 +1077,7 @@ public class ScheduledDeliveryHandlerTest extends Assert
       }
 
       @Override
-      public void setConsumersRefCount(ActiveMQServer server)
+      public void setConsumersRefCount(ReferenceCounter referenceCounter)
       {
 
       }

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/test/java/org/apache/activemq/core/settings/AddressSettingsTest.java
----------------------------------------------------------------------
diff --git a/activemq-server/src/test/java/org/apache/activemq/core/settings/AddressSettingsTest.java b/activemq-server/src/test/java/org/apache/activemq/core/settings/AddressSettingsTest.java
index 2d71668..4232420 100644
--- a/activemq-server/src/test/java/org/apache/activemq/core/settings/AddressSettingsTest.java
+++ b/activemq-server/src/test/java/org/apache/activemq/core/settings/AddressSettingsTest.java
@@ -46,7 +46,8 @@ public class AddressSettingsTest extends UnitTestCase
       Assert.assertEquals(AddressSettings.DEFAULT_SLOW_CONSUMER_THRESHOLD, addressSettings.getSlowConsumerThreshold());
       Assert.assertEquals(AddressSettings.DEFAULT_SLOW_CONSUMER_CHECK_PERIOD, addressSettings.getSlowConsumerCheckPeriod());
       Assert.assertEquals(AddressSettings.DEFAULT_SLOW_CONSUMER_POLICY, addressSettings.getSlowConsumerPolicy());
-
+      Assert.assertEquals(AddressSettings.DEFAULT_AUTO_CREATE_QUEUES, addressSettings.isAutoCreateJmsQueues());
+      Assert.assertEquals(AddressSettings.DEFAULT_AUTO_DELETE_QUEUES, addressSettings.isAutoDeleteJmsQueues());
    }
 
    @Test

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/activemq-server/src/test/resources/ConfigurationTest-full-config.xml
----------------------------------------------------------------------
diff --git a/activemq-server/src/test/resources/ConfigurationTest-full-config.xml b/activemq-server/src/test/resources/ConfigurationTest-full-config.xml
index 9180f93..3f2ab44 100644
--- a/activemq-server/src/test/resources/ConfigurationTest-full-config.xml
+++ b/activemq-server/src/test/resources/ConfigurationTest-full-config.xml
@@ -271,6 +271,8 @@
          <slow-consumer-threshold>10</slow-consumer-threshold>
          <slow-consumer-check-period>5</slow-consumer-check-period>
          <slow-consumer-policy>NOTIFY</slow-consumer-policy>
+         <auto-create-jms-queues>true</auto-create-jms-queues>
+         <auto-delete-jms-queues>true</auto-delete-jms-queues>
       </address-setting>
       <address-setting match="a2">
          <dead-letter-address>a2.1</dead-letter-address>
@@ -283,6 +285,8 @@
          <slow-consumer-threshold>20</slow-consumer-threshold>
          <slow-consumer-check-period>15</slow-consumer-check-period>
          <slow-consumer-policy>KILL</slow-consumer-policy>
+         <auto-create-jms-queues>false</auto-create-jms-queues>
+         <auto-delete-jms-queues>false</auto-delete-jms-queues>
       </address-setting>
    </address-settings>
    <connector-services>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/docs/user-manual/en/queue-attributes.md
----------------------------------------------------------------------
diff --git a/docs/user-manual/en/queue-attributes.md b/docs/user-manual/en/queue-attributes.md
index d534673..9892e69 100644
--- a/docs/user-manual/en/queue-attributes.md
+++ b/docs/user-manual/en/queue-attributes.md
@@ -95,6 +95,8 @@ entry that would be found in the `activemq-configuration.xml` file.
           <slow-consumer-threshold>-1</slow-consumer-threshold>
           <slow-consumer-policy>NOTIFY</slow-consumer-policy>
           <slow-consumer-check-period>5</slow-consumer-check-period>
+          <auto-create-queues>true</auto-create-queues>
+          <auto-delete-queues>true</auto-delete-queues>
        </address-setting>
     </address-settings>
 
@@ -176,3 +178,13 @@ on this notification.
 `slow-consumer-check-period`. How often to check for slow consumers on a
 particular queue. Measured in minutes. Default is 5. See ? for more
 information about slow consumer detection.
+
+`auto-create-jms-queues`. Whether or not the broker should automatically
+create a JMS queue when a JMS message is sent to a queue whose name fits
+the address `match` (remember, a JMS queue is just a core queue which has
+the same address and queue name) or a JMS consumer tries to connect to a
+queue whose name fits the address `match`. Queues which are auto-created
+are durable, non-temporary, and non-transient.
+
+`auto-delete-jms-queues`. Whether or not to the broker should automatically
+delete auto-created JMS queues when they have both 0 consumers and 0 messages.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 4f3f440..0f861f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
       <activemq.version.majorVersion>6</activemq.version.majorVersion>
       <activemq.version.minorVersion>0</activemq.version.minorVersion>
       <activemq.version.microVersion>0</activemq.version.microVersion>
-      <activemq.version.incrementingVersion>125,124,123,122</activemq.version.incrementingVersion>
+      <activemq.version.incrementingVersion>126,125,124,123,122</activemq.version.incrementingVersion>
       <activemq.version.versionSuffix>SNAPSHOT</activemq.version.versionSuffix>
       <activemq.version.versionTag>SNAPSHOT</activemq.version.versionTag>
       <ActiveMQ-Version>

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
----------------------------------------------------------------------
diff --git a/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java b/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
index 5ba28b5..f0039ff 100644
--- a/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
+++ b/tests/concurrent-tests/src/test/java/org/apache/activemq/tests/concurrent/server/impl/QueueTest.java
@@ -77,6 +77,7 @@ public class QueueTest extends UnitTestCase
                                              null,
                                              null,
                                              false,
+                                             false,
                                              false);
 
       FakeConsumer consumer = new FakeConsumer();

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoCreateJmsQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoCreateJmsQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoCreateJmsQueueTest.java
new file mode 100644
index 0000000..f76d631
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoCreateJmsQueueTest.java
@@ -0,0 +1,187 @@
+/**
+ * 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.tests.integration.client;
+
+import javax.jms.Connection;
+import javax.jms.InvalidDestinationException;
+import javax.jms.JMSSecurityException;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.core.security.Role;
+import org.apache.activemq.core.server.Queue;
+import org.apache.activemq.tests.util.JMSTestBase;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * @author Justin Bertram
+ */
+public class AutoCreateJmsQueueTest extends JMSTestBase
+{
+   @Test
+   public void testAutoCreateOnSendToQueue() throws Exception
+   {
+      Connection connection = cf.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      javax.jms.Queue queue = ActiveMQJMSClient.createQueue("test");
+
+      MessageProducer producer = session.createProducer(queue);
+
+      final int numMessages = 100;
+
+      for (int i = 0; i < numMessages; i++)
+      {
+         TextMessage mess = session.createTextMessage("msg" + i);
+         producer.send(mess);
+      }
+
+      producer.close();
+
+      MessageConsumer messageConsumer = session.createConsumer(queue);
+      connection.start();
+
+      for (int i = 0; i < numMessages; i++)
+      {
+         Message m = messageConsumer.receive(5000);
+         Assert.assertNotNull(m);
+      }
+
+      connection.close();
+   }
+
+   @Test
+   public void testAutoCreateOnSendToQueueSecurity() throws Exception
+   {
+      server.getSecurityManager().addUser("guest", "guest");
+      server.getSecurityManager().setDefaultUser("guest");
+      server.getSecurityManager().addRole("guest", "rejectAll");
+      Role role = new Role("rejectAll", false, false, false, false, false, false, false);
+      Set<Role> roles = new HashSet<Role>();
+      roles.add(role);
+      server.getSecurityRepository().addMatch("#", roles);
+      Connection connection = cf.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      javax.jms.Queue queue = ActiveMQJMSClient.createQueue("test");
+
+      try
+      {
+         MessageProducer producer = session.createProducer(queue);
+         Assert.fail("Creating a producer here should throw a JMSSecurityException");
+      }
+      catch (Exception e)
+      {
+         Assert.assertTrue(e instanceof JMSSecurityException);
+      }
+
+      connection.close();
+   }
+
+   @Test
+   public void testAutoCreateOnSendToTopic() throws Exception
+   {
+      Connection connection = cf.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      javax.jms.Topic topic = ActiveMQJMSClient.createTopic("test");
+
+      try
+      {
+         MessageProducer producer = session.createProducer(topic);
+         Assert.fail("Creating a producer here should throw an exception");
+      }
+      catch (Exception e)
+      {
+         Assert.assertTrue(e instanceof InvalidDestinationException);
+      }
+
+      connection.close();
+   }
+
+   @Test
+   public void testAutoCreateOnConsumeFromQueue() throws Exception
+   {
+      Connection connection = null;
+      connection = cf.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      javax.jms.Queue queue = ActiveMQJMSClient.createQueue("test");
+
+      MessageConsumer messageConsumer = session.createConsumer(queue);
+      connection.start();
+
+      Message m = messageConsumer.receive(500);
+      Assert.assertNull(m);
+
+      Queue q = (Queue) server.getPostOffice().getBinding(new SimpleString("jms.queue.test")).getBindable();
+      Assert.assertEquals(0, q.getMessageCount());
+      Assert.assertEquals(0, q.getMessagesAdded());
+      connection.close();
+   }
+
+   @Test
+   public void testAutoCreateOnConsumeFromTopic() throws Exception
+   {
+      Connection connection = null;
+      connection = cf.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      javax.jms.Topic topic = ActiveMQJMSClient.createTopic("test");
+
+      try
+      {
+         MessageConsumer messageConsumer = session.createConsumer(topic);
+         Assert.fail("Creating a consumer here should throw an exception");
+      }
+      catch (Exception e)
+      {
+         Assert.assertTrue(e instanceof InvalidDestinationException);
+      }
+
+      connection.close();
+   }
+
+   @Before
+   @Override
+   public void setUp() throws Exception
+   {
+      super.setUp();
+      server.getSecurityManager().addUser("guest", "guest");
+      server.getSecurityManager().setDefaultUser("guest");
+      server.getSecurityManager().addRole("guest", "allowAll");
+      Role role = new Role("allowAll", true, true, true, true, true, true, true);
+      Set<Role> roles = new HashSet<Role>();
+      roles.add(role);
+      server.getSecurityRepository().addMatch("#", roles);
+   }
+
+   protected boolean useSecurity()
+   {
+      return true;
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoDeleteJmsQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoDeleteJmsQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoDeleteJmsQueueTest.java
new file mode 100644
index 0000000..14cacf7
--- /dev/null
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/AutoDeleteJmsQueueTest.java
@@ -0,0 +1,84 @@
+/**
+ * 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.tests.integration.client;
+
+import javax.jms.Connection;
+import javax.jms.Message;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import org.apache.activemq.api.core.SimpleString;
+import org.apache.activemq.api.jms.ActiveMQJMSClient;
+import org.apache.activemq.core.server.Queue;
+import org.apache.activemq.tests.util.JMSTestBase;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author Justin Bertram
+ */
+public class AutoDeleteJmsQueueTest extends JMSTestBase
+{
+   @Test
+   public void testAutoDelete() throws Exception
+   {
+      Connection connection = cf.createConnection();
+      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+      javax.jms.Queue queue = ActiveMQJMSClient.createQueue("test");
+
+      MessageProducer producer = session.createProducer(queue);
+
+      final int numMessages = 100;
+
+      for (int i = 0; i < numMessages; i++)
+      {
+         TextMessage mess = session.createTextMessage("msg" + i);
+         producer.send(mess);
+      }
+
+      producer.close();
+
+      MessageConsumer messageConsumer = session.createConsumer(queue);
+      connection.start();
+
+      for (int i = 0; i < numMessages - 1; i++)
+      {
+         Message m = messageConsumer.receive(5000);
+         Assert.assertNotNull(m);
+      }
+
+      session.close();
+
+      // ensure the queue is still there
+      Queue q = (Queue) server.getPostOffice().getBinding(new SimpleString("jms.queue.test")).getBindable();
+      Assert.assertEquals(1, q.getMessageCount());
+      Assert.assertEquals(numMessages, q.getMessagesAdded());
+
+      session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+      messageConsumer = session.createConsumer(queue);
+      Message m = messageConsumer.receive(5000);
+      Assert.assertNotNull(m);
+
+      connection.close();
+
+      // ensure the queue was removed
+      Assert.assertNull(server.getPostOffice().getBinding(new SimpleString("jms.queue.test")));
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/HangConsumerTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/HangConsumerTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/HangConsumerTest.java
index b4a7977..e953e83 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/HangConsumerTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/HangConsumerTest.java
@@ -242,6 +242,7 @@ public class HangConsumerTest extends ServiceTestBase
                                     final PageSubscription pageSubscription,
                                     final boolean durable,
                                     final boolean temporary,
+                                    final boolean autoCreated,
                                     final ScheduledExecutorService scheduledExecutor,
                                     final PostOffice postOffice,
                                     final StorageManager storageManager,
@@ -255,6 +256,7 @@ public class HangConsumerTest extends ServiceTestBase
                pageSubscription,
                durable,
                temporary,
+               autoCreated,
                scheduledExecutor,
                postOffice,
                storageManager,
@@ -294,7 +296,8 @@ public class HangConsumerTest extends ServiceTestBase
                                   final Filter filter,
                                   final PageSubscription pageSubscription,
                                   final boolean durable,
-                                  final boolean temporary)
+                                  final boolean temporary,
+                                  final boolean autoCreated)
          {
             queue = new MyQueueWithBlocking(persistenceID,
                address,
@@ -303,6 +306,7 @@ public class HangConsumerTest extends ServiceTestBase
                pageSubscription,
                durable,
                temporary,
+               autoCreated,
                scheduledExecutor,
                postOffice,
                storageManager,
@@ -401,7 +405,7 @@ public class HangConsumerTest extends ServiceTestBase
 
 
       // Forcing a situation where the server would unexpectedly create a duplicated queue. The server should still start normally
-      LocalQueueBinding newBinding = new LocalQueueBinding(QUEUE, new QueueImpl(queueID, QUEUE, QUEUE, null, true, false, null, null, null, null, null), server.getNodeID());
+      LocalQueueBinding newBinding = new LocalQueueBinding(QUEUE, new QueueImpl(queueID, QUEUE, QUEUE, null, true, false, false, null, null, null, null, null), server.getNodeID());
       server.getStorageManager().addQueueBinding(txID, newBinding);
       server.getStorageManager().commitBindings(txID);
 

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/InterruptedLargeMessageTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/InterruptedLargeMessageTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/InterruptedLargeMessageTest.java
index 9db1ff1..0fb5ab2 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/InterruptedLargeMessageTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/InterruptedLargeMessageTest.java
@@ -506,6 +506,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase
                                PageSubscription pageSubscription,
                                boolean durable,
                                boolean temporary,
+                               boolean autoCreated,
                                ScheduledExecutorService scheduledExecutor,
                                PostOffice postOffice,
                                StorageManager storageManager,
@@ -519,6 +520,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase
                   pageSubscription,
                   durable,
                   temporary,
+                  autoCreated,
                   scheduledExecutor,
                   postOffice,
                   storageManager,
@@ -570,7 +572,8 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase
                                   Filter filter,
                                   PageSubscription pageSubscription,
                                   boolean durable,
-                                  boolean temporary)
+                                  boolean temporary,
+                                  boolean autoCreated)
          {
 
             return new NoPostACKQueue(persistenceID,
@@ -580,6 +583,7 @@ public class InterruptedLargeMessageTest extends LargeMessageTestBase
                                       pageSubscription,
                                       durable,
                                       temporary,
+                                      autoCreated,
                                       scheduledExecutor,
                                       postOffice,
                                       storageManager,

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingOrderTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingOrderTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingOrderTest.java
index a77ee94..fd2591f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingOrderTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/client/PagingOrderTest.java
@@ -749,7 +749,9 @@ public class PagingOrderTest extends ServiceTestBase
                                                           "PAGE",
                                                           -1,
                                                           10,
-                                                          "KILL");
+                                                          "KILL",
+                                                          true,
+                                                          true);
 
       ActiveMQJMSConnectionFactory cf = (ActiveMQJMSConnectionFactory) ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
                                                                                                                         new TransportConfiguration(INVM_CONNECTOR_FACTORY));
@@ -824,7 +826,9 @@ public class PagingOrderTest extends ServiceTestBase
                                                           "PAGE",
                                                           -1,
                                                           10,
-                                                          "KILL");
+                                                          "KILL",
+                                                          true,
+                                                          true);
 
       jmsServer.createQueue(true, "Q1", null, true, "/queue/Q1");
 

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/client/TopicCleanupTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/client/TopicCleanupTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/client/TopicCleanupTest.java
index bd264ec..55cd607 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/client/TopicCleanupTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/client/TopicCleanupTest.java
@@ -82,7 +82,7 @@ public class TopicCleanupTest extends JMSTestBase
          {
             long txid = storage.generateID();
 
-            final Queue queue = new QueueImpl(storage.generateID(), SimpleString.toSimpleString("jms.topic.topic"), SimpleString.toSimpleString("jms.topic.topic"), FilterImpl.createFilter(ActiveMQServerImpl.GENERIC_IGNORED_FILTER), true, false, server.getScheduledPool(), server.getPostOffice(),
+            final Queue queue = new QueueImpl(storage.generateID(), SimpleString.toSimpleString("jms.topic.topic"), SimpleString.toSimpleString("jms.topic.topic"), FilterImpl.createFilter(ActiveMQServerImpl.GENERIC_IGNORED_FILTER), true, false, false, server.getScheduledPool(), server.getPostOffice(),
                                               storage, server.getAddressSettingsRepository(), server.getExecutorFactory().getExecutor());
 
             LocalQueueBinding binding = new LocalQueueBinding(queue.getAddress(), queue, server.getNodeID());

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/jms2client/NonExistentQueueTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/jms2client/NonExistentQueueTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/jms2client/NonExistentQueueTest.java
index 1f3db36..e632d65 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/jms2client/NonExistentQueueTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/jms/jms2client/NonExistentQueueTest.java
@@ -62,7 +62,7 @@ public class NonExistentQueueTest extends JMSTestBase
    @Test
    public void sendToNonExistantDestination() throws Exception
    {
-      Destination destination = ActiveMQJMSClient.createQueue("DoesNotExist");
+      Destination destination = ActiveMQJMSClient.createTopic("DoesNotExist");
       TransportConfiguration transportConfiguration = new TransportConfiguration(InVMConnectorFactory.class.getName());
       ConnectionFactory localConnectionFactory = ActiveMQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF,
                                                                                                     transportConfiguration);

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlTest.java
index a795e35..3016d05 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlTest.java
@@ -507,6 +507,8 @@ public class ActiveMQServerControlTest extends ManagementTestBase
       long slowConsumerThreshold = 5;
       long slowConsumerCheckPeriod = 10;
       String slowConsumerPolicy = SlowConsumerPolicy.KILL.toString();
+      boolean autoCreateJmsQueues = false;
+      boolean autoDeleteJmsQueues = false;
 
       serverControl.addAddressSettings(addressMatch,
                                        DLA,
@@ -525,7 +527,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase
                                        addressFullMessagePolicy,
                                        slowConsumerThreshold,
                                        slowConsumerCheckPeriod,
-                                       slowConsumerPolicy);
+                                       slowConsumerPolicy,
+                                       autoCreateJmsQueues,
+                                       autoDeleteJmsQueues);
 
 
       boolean ex = false;
@@ -548,7 +552,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase
                                           addressFullMessagePolicy,
                                           slowConsumerThreshold,
                                           slowConsumerCheckPeriod,
-                                          slowConsumerPolicy);
+                                          slowConsumerPolicy,
+                                          autoCreateJmsQueues,
+                                          autoDeleteJmsQueues);
       }
       catch (Exception expected)
       {
@@ -578,6 +584,8 @@ public class ActiveMQServerControlTest extends ManagementTestBase
       assertEquals(slowConsumerThreshold, info.getSlowConsumerThreshold());
       assertEquals(slowConsumerCheckPeriod, info.getSlowConsumerCheckPeriod());
       assertEquals(slowConsumerPolicy, info.getSlowConsumerPolicy());
+      assertEquals(autoCreateJmsQueues, info.isAutoCreateJmsQueues());
+      assertEquals(autoDeleteJmsQueues, info.isAutoDeleteJmsQueues());
 
       serverControl.addAddressSettings(addressMatch,
                                        DLA,
@@ -596,7 +604,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase
                                        addressFullMessagePolicy,
                                        slowConsumerThreshold,
                                        slowConsumerCheckPeriod,
-                                       slowConsumerPolicy);
+                                       slowConsumerPolicy,
+                                       autoCreateJmsQueues,
+                                       autoDeleteJmsQueues);
 
 
       jsonString = serverControl.getAddressSettingsAsJSON(exactAddress);
@@ -618,6 +628,8 @@ public class ActiveMQServerControlTest extends ManagementTestBase
       assertEquals(slowConsumerThreshold, info.getSlowConsumerThreshold());
       assertEquals(slowConsumerCheckPeriod, info.getSlowConsumerCheckPeriod());
       assertEquals(slowConsumerPolicy, info.getSlowConsumerPolicy());
+      assertEquals(autoCreateJmsQueues, info.isAutoCreateJmsQueues());
+      assertEquals(autoDeleteJmsQueues, info.isAutoDeleteJmsQueues());
 
 
       ex = false;
@@ -640,7 +652,9 @@ public class ActiveMQServerControlTest extends ManagementTestBase
                                           addressFullMessagePolicy,
                                           slowConsumerThreshold,
                                           slowConsumerCheckPeriod,
-                                          slowConsumerPolicy);
+                                          slowConsumerPolicy,
+                                          autoCreateJmsQueues,
+                                          autoDeleteJmsQueues);
       }
       catch (Exception e)
       {

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlUsingCoreTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
index cd54124..019689f 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/management/ActiveMQServerControlUsingCoreTest.java
@@ -582,7 +582,9 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
                                         @Parameter(desc = "the policy to use when the address is full", name = "addressFullMessagePolicy") String addressFullMessagePolicy,
                                         @Parameter(desc = "when a consumer falls below this threshold in terms of messages consumed per second it will be considered 'slow'", name = "slowConsumerThreshold") long slowConsumerThreshold,
                                         @Parameter(desc = "how often (in seconds) to check for slow consumers", name = "slowConsumerCheckPeriod") long slowConsumerCheckPeriod,
-                                        @Parameter(desc = "the policy to use when a slow consumer is detected", name = "slowConsumerPolicy") String slowConsumerPolicy) throws Exception
+                                        @Parameter(desc = "the policy to use when a slow consumer is detected", name = "slowConsumerPolicy") String slowConsumerPolicy,
+                                        @Parameter(desc = "allow queues to be created automatically", name = "autoCreateJmsQueues") boolean autoCreateJmsQueues,
+                                        @Parameter(desc = "allow auto-created queues to be deleted automatically", name = "autoDeleteJmsQueues") boolean autoDeleteJmsQueues) throws Exception
          {
             proxy.invokeOperation("addAddressSettings",
                                   addressMatch,
@@ -602,7 +604,9 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
                                   addressFullMessagePolicy,
                                   slowConsumerThreshold,
                                   slowConsumerCheckPeriod,
-                                  slowConsumerPolicy);
+                                  slowConsumerPolicy,
+                                  autoCreateJmsQueues,
+                                  autoDeleteJmsQueues);
          }
 
          public void removeAddressSettings(String addressMatch) throws Exception

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/persistence/ExportFormatTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/persistence/ExportFormatTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/persistence/ExportFormatTest.java
index b905e46..fbd9e74 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/persistence/ExportFormatTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/tests/integration/persistence/ExportFormatTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.activemq.tests.integration.persistence;
 
+import org.junit.Ignore;
 import org.junit.Test;
 
 import java.io.StringReader;
@@ -47,37 +48,40 @@ public class ExportFormatTest extends ServiceTestBase
 
    // Case the format was changed, and the change was agreed, use _testCreateFormat to recreate this field
    String bindingsFile = "#File,JournalFileImpl: (activemq-bindings-1.bindings id = 1, recordID = 1)\n" +
-         "operation@AddRecord,id@2,userRecordType@24,length@8,isUpdate@false,compactCount@0,data@AAAAAH____8=\n" +
-         "operation@AddRecord,id@2,userRecordType@21,length@17,isUpdate@false,compactCount@0,data@AAAABEEAMQAAAAAEQQAxAAA=\n" +
-         "operation@AddRecord,id@20,userRecordType@24,length@8,isUpdate@false,compactCount@0,data@AAAAAAAAABQ=\n" +
-         "#File,JournalFileImpl: (activemq-bindings-2.bindings id = 2, recordID = 2)";
+      "operation@AddRecord,id@2,userRecordType@24,length@8,isUpdate@false,compactCount@0,data@AAAAAH____8=\n" +
+      "operation@AddRecordTX,txID@2,id@3,userRecordType@21,length@18,isUpdate@false,compactCount@0,data@AAAABEEAMQAAAAAEQQAxAAAA\n" +
+      "operation@Commit,txID@2,numberOfRecords@1\n" +
+      "operation@AddRecord,id@20,userRecordType@24,length@8,isUpdate@false,compactCount@0,data@AAAAAAAAABQ=\n" +
+      "#File,JournalFileImpl: (activemq-bindings-2.bindings id = 2, recordID = 2)";
 
    // Case the format was changed, and the change was agreed, use _testCreateFormat to recreate this field
    String journalFile = "#File,JournalFileImpl: (activemq-data-1.amq id = 1, recordID = 1)\n" +
-         "operation@AddRecordTX,txID@0,id@4,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABAEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP40EAQAAAAEAAAAGawBlAHkABgAAAAA=\n" +
-         "operation@UpdateTX,txID@0,id@4,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecordTX,txID@0,id@5,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABQEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP5EEAQAAAAEAAAAGawBlAHkABgAAAAE=\n" +
-         "operation@UpdateTX,txID@0,id@5,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecordTX,txID@0,id@6,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABgEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP5EEAQAAAAEAAAAGawBlAHkABgAAAAI=\n" +
-         "operation@UpdateTX,txID@0,id@6,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecordTX,txID@0,id@7,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABwEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP5EEAQAAAAEAAAAGawBlAHkABgAAAAM=\n" +
-         "operation@UpdateTX,txID@0,id@7,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecordTX,txID@0,id@8,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAACAEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP5EEAQAAAAEAAAAGawBlAHkABgAAAAQ=\n" +
-         "operation@UpdateTX,txID@0,id@8,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@Commit,txID@0,numberOfRecords@10\n" +
-         "operation@AddRecord,id@12,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADAEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP6gEAQAAAAEAAAAGawBlAHkABgAAAAU=\n" +
-         "operation@Update,id@12,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecord,id@13,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADQEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP6oEAQAAAAEAAAAGawBlAHkABgAAAAY=\n" +
-         "operation@Update,id@13,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecord,id@14,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADgEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP6sEAQAAAAEAAAAGawBlAHkABgAAAAc=\n" +
-         "operation@Update,id@14,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecord,id@15,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADwEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP60EAQAAAAEAAAAGawBlAHkABgAAAAg=\n" +
-         "operation@Update,id@15,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "operation@AddRecord,id@16,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAAEAEAAAAEQQAxAAAA_wAAAAAAAAAAAAABLLxYP64EAQAAAAEAAAAGawBlAHkABgAAAAk=\n" +
-         "operation@Update,id@16,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAI=\n" +
-         "#File,JournalFileImpl: (activemq-data-2.amq id = 2, recordID = 2)";
-
-   public void _testCreateFormat() throws Exception
+      "operation@AddRecordTX,txID@0,id@5,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABQEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2CfYEAQAAAAEAAAAGawBlAHkABgAAAAA=\n" +
+      "operation@UpdateTX,txID@0,id@5,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecordTX,txID@0,id@6,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABgEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2CfoEAQAAAAEAAAAGawBlAHkABgAAAAE=\n" +
+      "operation@UpdateTX,txID@0,id@6,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecordTX,txID@0,id@7,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAABwEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2CfoEAQAAAAEAAAAGawBlAHkABgAAAAI=\n" +
+      "operation@UpdateTX,txID@0,id@7,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecordTX,txID@0,id@8,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAACAEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2CfoEAQAAAAEAAAAGawBlAHkABgAAAAM=\n" +
+      "operation@UpdateTX,txID@0,id@8,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecordTX,txID@0,id@9,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAACQEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2CfoEAQAAAAEAAAAGawBlAHkABgAAAAQ=\n" +
+      "operation@UpdateTX,txID@0,id@9,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@Commit,txID@0,numberOfRecords@10\n" +
+      "operation@AddRecord,id@13,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADQEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2Cg0EAQAAAAEAAAAGawBlAHkABgAAAAU=\n" +
+      "operation@Update,id@13,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecord,id@14,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADgEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2Cg8EAQAAAAEAAAAGawBlAHkABgAAAAY=\n" +
+      "operation@Update,id@14,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecord,id@15,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAADwEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2ChMEAQAAAAEAAAAGawBlAHkABgAAAAc=\n" +
+      "operation@Update,id@15,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecord,id@16,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAAEAEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2ChcEAQAAAAEAAAAGawBlAHkABgAAAAg=\n" +
+      "operation@Update,id@16,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "operation@AddRecord,id@17,userRecordType@31,length@65,isUpdate@false,compactCount@0,data@AAAAEQAAAE4AAAAAAAAAEQEAAAAEQQAxAAAA_wAAAAAAAAAAAAABSuT2ChoEAQAAAAEAAAAGawBlAHkABgAAAAk=\n" +
+      "operation@Update,id@17,userRecordType@32,length@8,isUpdate@true,compactCount@0,data@AAAAAAAAAAM=\n" +
+      "#File,JournalFileImpl: (activemq-data-2.amq id = 2, recordID = 2)";
+
+   @Test
+   @Ignore // use this to recreate the format above. Notice we can't change the record format between releases
+   public void testCreateFormat() throws Exception
    {
       ActiveMQServer server = createServer(true);
       server.start();
@@ -86,7 +90,7 @@ public class ExportFormatTest extends ServiceTestBase
 
       ClientSessionFactory factory = createSessionFactory(locator);
       ClientSession session = factory.createSession(false, false, false);
-      session.createQueue("A1", "A1");
+      session.createQueue("A1", "A1", true);
 
       ClientProducer producer = session.createProducer("A1");
       for (int i = 0; i < 5; i++)

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java
----------------------------------------------------------------------
diff --git a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java
index c062fe8..5c686cb 100644
--- a/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java
+++ b/tests/jms-tests/src/test/java/org/apache/activemq/jms/tests/SessionTest.java
@@ -34,6 +34,7 @@ import javax.jms.XAConnection;
 import javax.jms.XASession;
 
 import org.apache.activemq.api.jms.JMSFactoryType;
+import org.apache.activemq.core.settings.impl.AddressSettings;
 import org.apache.activemq.jms.tests.util.ProxyAssertSupport;
 import org.junit.Test;
 
@@ -113,6 +114,10 @@ public class SessionTest extends ActiveMQServerTestCase
    @Test
    public void testCreateNonExistentQueue() throws Exception
    {
+      AddressSettings addressSettings = new AddressSettings();
+      addressSettings.setAutoCreateJmsQueues(false);
+      getJmsServer().getAddressSettingsRepository().addMatch("#", addressSettings);
+
       Connection conn = getConnectionFactory().createConnection();
       Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
       try
@@ -147,6 +152,10 @@ public class SessionTest extends ActiveMQServerTestCase
    @Test
    public void testCreateQueueWhileTopicWithSameNameExists() throws Exception
    {
+      AddressSettings addressSettings = new AddressSettings();
+      addressSettings.setAutoCreateJmsQueues(false);
+      getJmsServer().getAddressSettingsRepository().addMatch("#", addressSettings);
+
       Connection conn = getConnectionFactory().createConnection();
       Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
       try

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueImplTest.java
----------------------------------------------------------------------
diff --git a/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueImplTest.java b/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueImplTest.java
index c2fb1ac..e8bbf95 100644
--- a/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueImplTest.java
+++ b/tests/timing-tests/src/test/java/org/apache/activemq/tests/timing/core/server/impl/QueueImplTest.java
@@ -81,6 +81,7 @@ public class QueueImplTest extends UnitTestCase
                                   null,
                                   false,
                                   true,
+                                  false,
                                   scheduledExecutor,
                                   null,
                                   null,
@@ -158,6 +159,7 @@ public class QueueImplTest extends UnitTestCase
                                   null,
                                   false,
                                   true,
+                                  false,
                                   scheduledExecutor,
                                   null,
                                   null,
@@ -273,6 +275,7 @@ public class QueueImplTest extends UnitTestCase
                                   null,
                                   false,
                                   true,
+                                  false,
                                   scheduledExecutor,
                                   null,
                                   null,

http://git-wip-us.apache.org/repos/asf/activemq-6/blob/e293d80f/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/core/postoffice/impl/FakeQueue.java
----------------------------------------------------------------------
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/core/postoffice/impl/FakeQueue.java b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/core/postoffice/impl/FakeQueue.java
index b88ee6e..1be23ea 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/core/postoffice/impl/FakeQueue.java
+++ b/tests/unit-tests/src/test/java/org/apache/activemq/tests/unit/core/postoffice/impl/FakeQueue.java
@@ -25,7 +25,6 @@ import org.apache.activemq.api.core.SimpleString;
 import org.apache.activemq.core.filter.Filter;
 import org.apache.activemq.core.paging.cursor.PageSubscription;
 import org.apache.activemq.core.server.Consumer;
-import org.apache.activemq.core.server.ActiveMQServer;
 import org.apache.activemq.core.server.MessageReference;
 import org.apache.activemq.core.server.Queue;
 import org.apache.activemq.core.server.RoutingContext;
@@ -60,7 +59,7 @@ public class FakeQueue implements Queue
    }
 
    @Override
-   public void setConsumersRefCount(ActiveMQServer server)
+   public void setConsumersRefCount(ReferenceCounter referenceCounter)
    {
 
    }
@@ -428,6 +427,12 @@ public class FakeQueue implements Queue
    }
 
    @Override
+   public boolean isAutoCreated()
+   {
+      return false;
+   }
+
+   @Override
    public LinkedListIterator<MessageReference> iterator()
    {
       // no-op


Mime
View raw message