use of org.apache.activemq.network.DemandForwardingBridge in project activemq-artemis by apache.
the class ThreeBrokerQueueNetworkUsingTcpTest method bridgeBrokers.
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
remoteURI = remoteTransports.get(0).getConnectUri();
localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
config.setBrokerName(localBroker.getBrokerName());
DemandForwardingBridge bridge = new DemandForwardingBridge(config, TransportFactory.connect(localURI), TransportFactory.connect(remoteURI));
bridge.setBrokerService(localBroker);
bridges.add(bridge);
bridge.start();
} else {
throw new Exception("Remote broker or local broker is not using tcp connectors");
}
} else {
throw new Exception("Remote broker or local broker has no registered connectors.");
}
maxSetupTime = 2000;
}
use of org.apache.activemq.network.DemandForwardingBridge in project activemq-artemis by apache.
the class ThreeBrokerTopicNetworkUsingTcpTest method bridgeBrokers.
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
remoteURI = remoteTransports.get(0).getConnectUri();
localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
config.setBrokerName(localBroker.getBrokerName());
DemandForwardingBridge bridge = new DemandForwardingBridge(config, TransportFactory.connect(localURI), TransportFactory.connect(remoteURI));
bridge.setBrokerService(localBroker);
bridges.add(bridge);
bridge.start();
} else {
throw new Exception("Remote broker or local broker is not using tcp connectors");
}
} else {
throw new Exception("Remote broker or local broker has no registered connectors.");
}
maxSetupTime = 2000;
}
use of org.apache.activemq.network.DemandForwardingBridge in project activemq-artemis by apache.
the class MultiBrokersMultiClientsUsingTcpTest method bridgeBrokers.
protected void bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker) throws Exception {
List<TransportConnector> remoteTransports = remoteBroker.getTransportConnectors();
List<TransportConnector> localTransports = localBroker.getTransportConnectors();
URI remoteURI;
URI localURI;
if (!remoteTransports.isEmpty() && !localTransports.isEmpty()) {
remoteURI = remoteTransports.get(0).getConnectUri();
localURI = localTransports.get(0).getConnectUri();
// Ensure that we are connecting using tcp
if (remoteURI.toString().startsWith("tcp:") && localURI.toString().startsWith("tcp:")) {
NetworkBridgeConfiguration config = new NetworkBridgeConfiguration();
config.setBrokerName(localBroker.getBrokerName());
DemandForwardingBridge bridge = new DemandForwardingBridge(config, TransportFactory.connect(localURI), TransportFactory.connect(remoteURI));
bridge.setBrokerService(localBroker);
bridges.add(bridge);
bridge.start();
} else {
throw new Exception("Remote broker or local broker is not using tcp connectors");
}
} else {
throw new Exception("Remote broker or local broker has no registered connectors.");
}
}
Aggregations