Search in sources :

Example 1 with NetworkBridgeConfiguration

use of org.apache.activemq.network.NetworkBridgeConfiguration 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;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkBridgeConfiguration(org.apache.activemq.network.NetworkBridgeConfiguration) DemandForwardingBridge(org.apache.activemq.network.DemandForwardingBridge) URI(java.net.URI)

Example 2 with NetworkBridgeConfiguration

use of org.apache.activemq.network.NetworkBridgeConfiguration 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;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkBridgeConfiguration(org.apache.activemq.network.NetworkBridgeConfiguration) DemandForwardingBridge(org.apache.activemq.network.DemandForwardingBridge) URI(java.net.URI)

Example 3 with NetworkBridgeConfiguration

use of org.apache.activemq.network.NetworkBridgeConfiguration 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.");
    }
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkBridgeConfiguration(org.apache.activemq.network.NetworkBridgeConfiguration) DemandForwardingBridge(org.apache.activemq.network.DemandForwardingBridge) URI(java.net.URI)

Aggregations

URI (java.net.URI)3 TransportConnector (org.apache.activemq.broker.TransportConnector)3 DemandForwardingBridge (org.apache.activemq.network.DemandForwardingBridge)3 NetworkBridgeConfiguration (org.apache.activemq.network.NetworkBridgeConfiguration)3