1 18 package org.apache.activemq.usecases; 19 20 import org.apache.activemq.broker.BrokerService; 21 import org.apache.activemq.broker.TransportConnector; 22 import org.apache.activemq.network.DemandForwardingBridge; 23 import org.apache.activemq.network.NetworkBridgeConfiguration; 24 import org.apache.activemq.transport.TransportFactory; 25 26 import java.util.List ; 27 import java.util.ArrayList ; 28 import java.net.URI ; 29 30 33 public class ThreeBrokerQueueNetworkUsingTcpTest extends ThreeBrokerQueueNetworkTest { 34 protected List bridges; 35 36 protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception { 37 List remoteTransports = remoteBroker.getTransportConnectors(); 38 List localTransports = localBroker.getTransportConnectors(); 39 40 URI remoteURI, localURI; 41 if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) { 42 remoteURI = ((TransportConnector)remoteTransports.get(0)).getConnectUri(); 43 localURI = ((TransportConnector)localTransports.get(0)).getConnectUri(); 44 45 if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) { 47 NetworkBridgeConfiguration config = new NetworkBridgeConfiguration(); 48 config.setBrokerName(localBroker.getBrokerName()); 49 DemandForwardingBridge bridge = new DemandForwardingBridge(config,TransportFactory.connect(localURI), 50 TransportFactory.connect(remoteURI)); 51 bridges.add(bridge); 52 53 bridge.start(); 54 } else { 55 throw new Exception ("Remote broker or local broker is not using tcp connectors"); 56 } 57 } else { 58 throw new Exception ("Remote broker or local broker has no registered connectors."); 59 } 60 61 MAX_SETUP_TIME = 2000; 62 } 63 64 public void setUp() throws Exception { 65 super.setUp(); 66 67 bridges = new ArrayList (); 68 } 69 } 70 | Popular Tags |