activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [1/2] activemq-artemis git commit: ARTEMIS-1361 - Support Updating queue config from broker.xml at runtime
Date Sat, 26 Aug 2017 02:47:01 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master 035890e2a -> 0a101c06a


ARTEMIS-1361 - Support Updating queue config from broker.xml at runtime 

Add support to update Queue config via reload using existing updateQueue method at runtime.
Add/extend unit test cases to include testing reload of queue config.

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

Branch: refs/heads/master
Commit: 9fbbb7c416e866a96682509ee9f00c1d629ca8dd
Parents: 035890e
Author: Michael Andre Pearce <Michael.Andre.Pearce@me.com>
Authored: Tue Aug 22 09:16:48 2017 +0100
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Fri Aug 25 22:46:50 2017 -0400

----------------------------------------------------------------------
 .../artemis/core/server/impl/ActiveMQServerImpl.java | 14 ++++++++++++--
 .../artemis/tests/integration/jms/RedeployTest.java  | 15 +++++++++++++++
 .../test/resources/reload-address-queues-updated.xml |  5 +++++
 .../src/test/resources/reload-address-queues.xml     |  5 +++++
 4 files changed, 37 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9fbbb7c4/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 5d0afaa..4093e21 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
@@ -2511,10 +2511,20 @@ public class ActiveMQServerImpl implements ActiveMQServer {
 
    private void deployQueuesFromListCoreQueueConfiguration(List<CoreQueueConfiguration>
queues) throws Exception {
       for (CoreQueueConfiguration config : queues) {
-         ActiveMQServerLogger.LOGGER.deployQueue(SimpleString.toSimpleString(config.getName()));
+         addOrUpdateQueue(config);
+      }
+   }
 
-         createQueue(SimpleString.toSimpleString(config.getAddress()), config.getRoutingType(),
SimpleString.toSimpleString(config.getName()), SimpleString.toSimpleString(config.getFilterString()),
null, config.isDurable(), false, true, false, false, config.getMaxConsumers(), config.getPurgeOnNoConsumers(),
true);
+   private Queue addOrUpdateQueue(CoreQueueConfiguration config) throws Exception {
+      SimpleString queueName = SimpleString.toSimpleString(config.getName());
+      ActiveMQServerLogger.LOGGER.deployQueue(queueName);
+      Queue queue = updateQueue(config.getName(), config.getRoutingType(), config.getMaxConsumers(),
config.getPurgeOnNoConsumers());
+      if (queue == null) {
+         queue = createQueue(SimpleString.toSimpleString(config.getAddress()), config.getRoutingType(),
+            queueName, SimpleString.toSimpleString(config.getFilterString()), null,
+            config.isDurable(), false, true, false, false, config.getMaxConsumers(), config.getPurgeOnNoConsumers(),
true);
       }
+      return queue;
    }
 
    private void deployQueuesFromConfiguration() throws Exception {

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9fbbb7c4/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
index da50ac2..f474e71 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/RedeployTest.java
@@ -32,6 +32,7 @@ import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
 import org.apache.activemq.artemis.api.core.SimpleString;
+import org.apache.activemq.artemis.core.postoffice.QueueBinding;
 import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
 import org.apache.activemq.artemis.jms.server.embedded.EmbeddedJMS;
@@ -147,6 +148,10 @@ public class RedeployTest extends ActiveMQTestBase {
          Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_1"));
          Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_2"));
 
+         Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change"));
+         Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue"));
+         Assert.assertEquals(10, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers());
+         Assert.assertEquals(false, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers());
 
          Files.copy(url2.openStream(), brokerXML, StandardCopyOption.REPLACE_EXISTING);
          brokerXML.toFile().setLastModified(System.currentTimeMillis() + 1000);
@@ -164,6 +169,11 @@ public class RedeployTest extends ActiveMQTestBase {
          Assert.assertNotNull(getAddressInfo(embeddedJMS, "permanent_test_queue_removal"));
          Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_1"));
          Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "permanent_test_queue_removal").contains("permanent_test_queue_removal_queue_2"));
+
+         Assert.assertNotNull(getAddressInfo(embeddedJMS, "config_test_queue_change"));
+         Assert.assertTrue(listQueuesNamesForAddress(embeddedJMS, "config_test_queue_change").contains("config_test_queue_change_queue"));
+         Assert.assertEquals(1, getQueue(embeddedJMS, "config_test_queue_change_queue").getMaxConsumers());
+         Assert.assertEquals(true, getQueue(embeddedJMS, "config_test_queue_change_queue").isPurgeOnNoConsumers());
       } finally {
          embeddedJMS.stop();
       }
@@ -173,6 +183,11 @@ public class RedeployTest extends ActiveMQTestBase {
       return embeddedJMS.getActiveMQServer().getPostOffice().getAddressInfo(SimpleString.toSimpleString(address));
    }
 
+   private org.apache.activemq.artemis.core.server.Queue getQueue(EmbeddedJMS embeddedJMS,
String queueName) throws Exception {
+      QueueBinding queueBinding = (QueueBinding) embeddedJMS.getActiveMQServer().getPostOffice().getBinding(SimpleString.toSimpleString(queueName));
+      return queueBinding == null ? null : queueBinding.getQueue();
+   }
+
    private List<String> listQueuesNamesForAddress(EmbeddedJMS embeddedJMS, String address)
throws Exception {
       return embeddedJMS.getActiveMQServer().getPostOffice().listQueuesForAddress(SimpleString.toSimpleString(address)).stream().map(
           org.apache.activemq.artemis.core.server.Queue::getName).map(SimpleString::toString).collect(Collectors.toList());

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9fbbb7c4/tests/integration-tests/src/test/resources/reload-address-queues-updated.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-address-queues-updated.xml
b/tests/integration-tests/src/test/resources/reload-address-queues-updated.xml
index 17a035e..1187baf 100644
--- a/tests/integration-tests/src/test/resources/reload-address-queues-updated.xml
+++ b/tests/integration-tests/src/test/resources/reload-address-queues-updated.xml
@@ -123,6 +123,11 @@ under the License.
                <queue name="permanent_test_queue_removal_queue_1"/>
             </multicast>
          </address>
+         <address name="config_test_queue_change">
+            <multicast>
+               <queue name="config_test_queue_change_queue" max-consumers="1" purge-on-no-consumers="true"
/>
+            </multicast>
+         </address>
       </addresses>
    </core>
 </configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/9fbbb7c4/tests/integration-tests/src/test/resources/reload-address-queues.xml
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/resources/reload-address-queues.xml b/tests/integration-tests/src/test/resources/reload-address-queues.xml
index 8fd2e9e..c394cfa 100644
--- a/tests/integration-tests/src/test/resources/reload-address-queues.xml
+++ b/tests/integration-tests/src/test/resources/reload-address-queues.xml
@@ -142,6 +142,11 @@ under the License.
                <queue name="permanent_test_address_removal_queue"/>
             </multicast>
          </address>
+         <address name="config_test_queue_change">
+            <multicast>
+               <queue name="config_test_queue_change_queue" max-consumers="10" purge-on-no-consumers="false"
/>
+            </multicast>
+         </address>
       </addresses>
    </core>
 </configuration>


Mime
View raw message