git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1213210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2011-12-12 12:25:19 +00:00
parent 8d0cf31f84
commit 4c8ab44698
4 changed files with 92 additions and 10 deletions

View File

@ -282,15 +282,17 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
remoteBroker.oneway(producerInfo); remoteBroker.oneway(producerInfo);
// Listen to consumer advisory messages on the remote broker to // Listen to consumer advisory messages on the remote broker to
// determine demand. // determine demand.
demandConsumerInfo = new ConsumerInfo(remoteSessionInfo, 1); if (!configuration.isStaticBridge()) {
demandConsumerInfo.setDispatchAsync(configuration.isDispatchAsync()); demandConsumerInfo = new ConsumerInfo(remoteSessionInfo, 1);
String advisoryTopic = configuration.getDestinationFilter(); demandConsumerInfo.setDispatchAsync(configuration.isDispatchAsync());
if (configuration.isBridgeTempDestinations()) { String advisoryTopic = configuration.getDestinationFilter();
advisoryTopic += "," + AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC; if (configuration.isBridgeTempDestinations()) {
advisoryTopic += "," + AdvisorySupport.TEMP_DESTINATION_COMPOSITE_ADVISORY_TOPIC;
}
demandConsumerInfo.setDestination(new ActiveMQTopic(advisoryTopic));
demandConsumerInfo.setPrefetchSize(configuration.getPrefetchSize());
remoteBroker.oneway(demandConsumerInfo);
} }
demandConsumerInfo.setDestination(new ActiveMQTopic(advisoryTopic));
demandConsumerInfo.setPrefetchSize(configuration.getPrefetchSize());
remoteBroker.oneway(demandConsumerInfo);
startedLatch.countDown(); startedLatch.countDown();
} }
} }

View File

@ -52,6 +52,7 @@ public class NetworkBridgeConfiguration {
private boolean suppressDuplicateTopicSubscriptions = true; private boolean suppressDuplicateTopicSubscriptions = true;
private boolean alwaysSyncSend = false; private boolean alwaysSyncSend = false;
private boolean staticBridge = false;
/** /**
* @return the conduitSubscriptions * @return the conduitSubscriptions
@ -359,4 +360,12 @@ public class NetworkBridgeConfiguration {
public void setConsumerPriorityBase(int consumerPriorityBase) { public void setConsumerPriorityBase(int consumerPriorityBase) {
this.consumerPriorityBase = consumerPriorityBase; this.consumerPriorityBase = consumerPriorityBase;
} }
public boolean isStaticBridge() {
return staticBridge;
}
public void setStaticBridge(boolean staticBridge) {
this.staticBridge = staticBridge;
}
} }

View File

@ -87,11 +87,11 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport {
return bridgeBrokers(localBrokerName, remoteBrokerName, false, 1, true); 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 localBroker = brokers.get(localBrokerName).broker;
BrokerService remoteBroker = brokers.get(remoteBrokerName).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 { protected NetworkConnector bridgeBrokers(String localBrokerName, String remoteBrokerName, boolean dynamicOnly, int networkTTL, boolean conduit) throws Exception {

View File

@ -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"));
}
}