activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cshan...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6035
Date Thu, 05 Nov 2015 13:35:30 GMT
Repository: activemq
Updated Branches:
  refs/heads/master b3d35472f -> 5db9af8b2


https://issues.apache.org/jira/browse/AMQ-6035

Adding a flag to be able to specificy when to apply changes immediately
after updating the virtual destinations using the Java runtime plugin.


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

Branch: refs/heads/master
Commit: 5db9af8b24cea9ab9460abd1c06221e1f08d6d48
Parents: b3d3547
Author: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Authored: Thu Nov 5 13:34:08 2015 +0000
Committer: Christopher L. Shannon (cshannon) <christopher.l.shannon@gmail.com>
Committed: Thu Nov 5 13:34:08 2015 +0000

----------------------------------------------------------------------
 .../AbstractRuntimeConfigurationBroker.java     | 21 ++++++++++++
 .../java/JavaRuntimeConfigurationBroker.java    | 15 ++++++++
 .../activemq/java/JavaVirtualDestTest.java      | 36 ++++++++++++++++++++
 3 files changed, 72 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/5db9af8b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/AbstractRuntimeConfigurationBroker.java
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/AbstractRuntimeConfigurationBroker.java
b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/AbstractRuntimeConfigurationBroker.java
index 1306096..a430339 100644
--- a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/AbstractRuntimeConfigurationBroker.java
+++ b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/AbstractRuntimeConfigurationBroker.java
@@ -122,6 +122,27 @@ public class AbstractRuntimeConfigurationBroker extends BrokerFilter
{
         }
     }
 
+    /**
+     * Apply the destination work immediately instead of waiting for
+     * a connection add or destination add
+     *
+     * @throws Exception
+     */
+    protected void applyDestinationWork() throws Exception {
+        Runnable work = addDestinationWork.poll();
+        if (work != null) {
+            try {
+                addDestinationBarrier.writeLock().lockInterruptibly();
+                do {
+                    work.run();
+                    work = addDestinationWork.poll();
+                } while (work != null);
+            } finally {
+                addDestinationBarrier.writeLock().unlock();
+            }
+        }
+    }
+
     protected void debug(String s) {
         LOG.debug(s);
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/5db9af8b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/java/JavaRuntimeConfigurationBroker.java
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/java/JavaRuntimeConfigurationBroker.java
b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/java/JavaRuntimeConfigurationBroker.java
index cd61f22..ca4fd50 100644
--- a/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/java/JavaRuntimeConfigurationBroker.java
+++ b/activemq-runtime-config/src/main/java/org/apache/activemq/plugin/java/JavaRuntimeConfigurationBroker.java
@@ -61,6 +61,21 @@ public class JavaRuntimeConfigurationBroker extends AbstractRuntimeConfiguration
         });
     }
 
+    /**
+     * Set the virtual destinations and apply immediately, instead of waiting for a new
+     * destination or connection to trigger the work.
+     *
+     * @param virtualDestinations
+     * @param applyImmediately
+     * @throws Exception
+     */
+    public void setVirtualDestinations(final VirtualDestination[] virtualDestinations, boolean
applyImmediately) throws Exception {
+        setVirtualDestinations(virtualDestinations);
+        if (applyImmediately) {
+            this.applyDestinationWork();
+        }
+    }
+
     //New Destinations
     public void setDestinations(final ActiveMQDestination[] destinations) {
         for (ActiveMQDestination destination : destinations) {

http://git-wip-us.apache.org/repos/asf/activemq/blob/5db9af8b/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaVirtualDestTest.java
----------------------------------------------------------------------
diff --git a/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaVirtualDestTest.java
b/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaVirtualDestTest.java
index fd8d407..c7db206 100644
--- a/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaVirtualDestTest.java
+++ b/activemq-runtime-config/src/test/java/org/apache/activemq/java/JavaVirtualDestTest.java
@@ -90,6 +90,7 @@ public class JavaVirtualDestTest extends AbstractVirtualDestTest {
         TimeUnit.SECONDS.sleep(SLEEP);
         assertSame("same instance", newValue, brokerService.getDestinationInterceptors()[0]);
     }
+
     @Test
     public void testNewComposite() throws Exception {
         startBroker(new BrokerService());
@@ -105,6 +106,21 @@ public class JavaVirtualDestTest extends AbstractVirtualDestTest {
         exerciseCompositeQueue("VirtualDestination.CompositeQueue", "VirtualDestination.QueueConsumer");
     }
 
+    @Test
+    public void testNewCompositeApplyImmediately() throws Exception {
+        startBroker(new BrokerService());
+        assertTrue("broker alive", brokerService.isStarted());
+
+        CompositeQueue queue = buildCompositeQueue("VirtualDestination.CompositeQueue",
+                Arrays.asList(new ActiveMQQueue("VirtualDestination.QueueConsumer"),
+                new ActiveMQTopic("VirtualDestination.TopicConsumer")));
+
+        javaConfigBroker.setVirtualDestinations(new VirtualDestination[]{queue}, true);
+        TimeUnit.SECONDS.sleep(SLEEP);
+
+        exerciseCompositeQueue("VirtualDestination.CompositeQueue", "VirtualDestination.QueueConsumer");
+    }
+
 
     @Test
     public void testModComposite() throws Exception {
@@ -272,6 +288,26 @@ public class JavaVirtualDestTest extends AbstractVirtualDestTest {
         assertEquals("still one interceptor", 1, brokerService.getDestinationInterceptors().length);
     }
 
+    @Test
+    public void testModApplyImmediately() throws Exception {
+        final BrokerService brokerService = new BrokerService();
+        brokerService.setDestinationInterceptors(new DestinationInterceptor[] {
+                buildInterceptor(new VirtualDestination[]{buildVirtualTopic("A.>", false)})});
+
+        startBroker(brokerService);
+        assertTrue("broker alive", brokerService.isStarted());
+
+        assertEquals("one interceptor", 1, brokerService.getDestinationInterceptors().length);
+        exerciseVirtualTopic("A.Default");
+
+        //apply new config
+        javaConfigBroker.setVirtualDestinations(new VirtualDestination[]{buildVirtualTopic("B.>",
false)}, true);
+        TimeUnit.SECONDS.sleep(SLEEP);
+        exerciseVirtualTopic("B.Default");
+
+        assertEquals("still one interceptor", 1, brokerService.getDestinationInterceptors().length);
+    }
+
 
     @Test
     public void testModWithMirroredQueue() throws Exception {


Mime
View raw message