mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-3632 - staticBridge
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1213210 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8d0cf31f84
commit
4c8ab44698
|
@ -282,15 +282,17 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
|
|||
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;
|
||||
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);
|
||||
}
|
||||
demandConsumerInfo.setDestination(new ActiveMQTopic(advisoryTopic));
|
||||
demandConsumerInfo.setPrefetchSize(configuration.getPrefetchSize());
|
||||
remoteBroker.oneway(demandConsumerInfo);
|
||||
startedLatch.countDown();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,11 +87,11 @@ public class JmsMultipleBrokersTestSupport extends CombinationTestSupport {
|
|||
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 {
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue