activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1213210 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/network/ test/java/org/apache/activemq/ test/java/org/apache/activemq/usecases/
Date Mon, 12 Dec 2011 12:25:20 GMT
Author: dejanb
Date: Mon Dec 12 12:25:19 2011
New Revision: 1213210

URL: http://svn.apache.org/viewvc?rev=1213210&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-3632 - staticBridge

Added:
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java
Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java?rev=1213210&r1=1213209&r2=1213210&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java
Mon Dec 12 12:25:19 2011
@@ -282,15 +282,17 @@ public abstract class DemandForwardingBr
                 remoteBroker.oneway(producerInfo);
                 // Listen to consumer advisory messages on the remote broker to
                 // determine demand.
-                demandConsumerInfo = new ConsumerInfo(remoteSessionInfo, 1);
-                demandConsumerInfo.setDispatchAsync(configuration.isDispatchAsync());
-                String advisoryTopic = configuration.getDestinationFilter();
-                if (configuration.isBridgeTempDestinations()) {
-                    advisoryTopic += "," + AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC;
-                }
-                demandConsumerInfo.setDestination(new ActiveMQTopic(advisoryTopic));
-                demandConsumerInfo.setPrefetchSize(configuration.getPrefetchSize());
-                remoteBroker.oneway(demandConsumerInfo);
+                if (!configuration.isStaticBridge()) {
+                    demandConsumerInfo = new ConsumerInfo(remoteSessionInfo, 1);
+                    demandConsumerInfo.setDispatchAsync(configuration.isDispatchAsync());
+                    String advisoryTopic = configuration.getDestinationFilter();
+                    if (configuration.isBridgeTempDestinations()) {
+                        advisoryTopic += "," + AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC;
+                    }
+                    demandConsumerInfo.setDestination(new ActiveMQTopic(advisoryTopic));
+                    demandConsumerInfo.setPrefetchSize(configuration.getPrefetchSize());
+                    remoteBroker.oneway(demandConsumerInfo);
+                }
                 startedLatch.countDown();
             }
         }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java?rev=1213210&r1=1213209&r2=1213210&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/NetworkBridgeConfiguration.java
Mon Dec 12 12:25:19 2011
@@ -52,6 +52,7 @@ public class NetworkBridgeConfiguration 
     private boolean suppressDuplicateTopicSubscriptions = true;
 
     private boolean alwaysSyncSend = false;
+    private boolean staticBridge = false;
 
     /**
      * @return the conduitSubscriptions
@@ -359,4 +360,12 @@ public class NetworkBridgeConfiguration 
     public void setConsumerPriorityBase(int consumerPriorityBase) {
         this.consumerPriorityBase = consumerPriorityBase;
     }
+
+    public boolean isStaticBridge() {
+        return staticBridge;
+    }
+
+    public void setStaticBridge(boolean staticBridge) {
+        this.staticBridge = staticBridge;
+    }
 }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java?rev=1213210&r1=1213209&r2=1213210&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/JmsMultipleBrokersTestSupport.java
Mon Dec 12 12:25:19 2011
@@ -87,11 +87,11 @@ public class JmsMultipleBrokersTestSuppo
         return bridgeBrokers(localBrokerName, remoteBrokerName, false, 1, true);
     }
 
-    protected void bridgeBrokers(String localBrokerName, String remoteBrokerName, boolean
dynamicOnly) throws Exception {
+    protected NetworkConnector bridgeBrokers(String localBrokerName, String remoteBrokerName,
boolean dynamicOnly) throws Exception {
         BrokerService localBroker = brokers.get(localBrokerName).broker;
         BrokerService remoteBroker = brokers.get(remoteBrokerName).broker;
 
-        bridgeBrokers(localBroker, remoteBroker, dynamicOnly, 1, true, false);
+        return bridgeBrokers(localBroker, remoteBroker, dynamicOnly, 1, true, false);
     }
 
     protected NetworkConnector bridgeBrokers(String localBrokerName, String remoteBrokerName,
boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {

Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java?rev=1213210&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java
(added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/usecases/StaticNetworkTest.java
Mon Dec 12 12:25:19 2011
@@ -0,0 +1,71 @@
+/**
+ * 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.usecases;
+
+import org.apache.activemq.JmsMultipleBrokersTestSupport;
+import org.apache.activemq.command.ActiveMQDestination;
+import org.apache.activemq.network.NetworkConnector;
+import org.apache.activemq.util.MessageIdList;
+
+import javax.jms.MessageConsumer;
+import java.net.URI;
+
+public class StaticNetworkTest extends JmsMultipleBrokersTestSupport {
+
+    public void testStaticNetwork() throws Exception {
+        // Setup destination
+        ActiveMQDestination dest = createDestination("TEST", false);
+        ActiveMQDestination dest1 = createDestination("TEST1", false);
+
+        NetworkConnector bridgeAB =bridgeBrokers("BrokerA", "BrokerB", true);
+        bridgeAB.addStaticallyIncludedDestination(dest);
+        bridgeAB.setStaticBridge(true);
+
+        startAllBrokers();
+        waitForBridgeFormation();
+
+        MessageConsumer consumer1 = createConsumer("BrokerB", dest);
+        MessageConsumer consumer2 = createConsumer("BrokerB", dest1);
+
+
+        Thread.sleep(1000);
+
+
+        sendMessages("BrokerA", dest,  1);
+        sendMessages("BrokerA", dest1, 1);
+
+        MessageIdList msgs1 = getConsumerMessages("BrokerB", consumer1);
+        MessageIdList msgs2 = getConsumerMessages("BrokerB", consumer2);
+
+        msgs1.waitForMessagesToArrive(1);
+
+        Thread.sleep(1000);
+
+        assertEquals(1, msgs1.getMessageCount());
+        assertEquals(0, msgs2.getMessageCount());
+
+    }
+
+    @Override
+    public void setUp() throws Exception {
+        super.setAutoFail(true);
+        super.setUp();
+        createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=false&useJmx=false"));
+        createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=false&useJmx=false"));
+    }
+
+}



Mime
View raw message