Search in sources :

Example 1 with DiscoveryNetworkConnector

use of org.apache.activemq.network.DiscoveryNetworkConnector in project fabric8 by jboss-fuse.

the class ActiveMQServiceFactory method createNetworkConnector.

private NetworkConnector createNetworkConnector(URI uri, Properties properties) throws URISyntaxException, IOException {
    NetworkConnector nc = new DiscoveryNetworkConnector(uri);
    Map<String, Object> networkProperties = new HashMap<String, Object>();
    // use default credentials for network connector (if none was specified)
    networkProperties.put("network.userName", "admin");
    networkProperties.put("network.password", properties.getProperty("zookeeper.password"));
    for (String k : properties.stringPropertyNames()) {
        networkProperties.put(k, properties.getProperty(k));
    }
    IntrospectionSupport.setProperties(nc, networkProperties, "network.");
    return nc;
}
Also used : HashMap(java.util.HashMap) NetworkConnector(org.apache.activemq.network.NetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector)

Example 2 with DiscoveryNetworkConnector

use of org.apache.activemq.network.DiscoveryNetworkConnector in project activemq-artemis by apache.

the class JmsMultipleBrokersTestSupport method bridgeBrokers.

// Overwrite this method to specify how you want to bridge the two brokers
// By default, bridge them using add network connector of the local broker
// and the first connector of the remote broker
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
    List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
    URI remoteURI;
    if (!transportConnectors.isEmpty()) {
        remoteURI = transportConnectors.get(0).getConnectUri();
        String uri = "static:(" + remoteURI + ")";
        if (failover) {
            uri = "static:(failover:(" + remoteURI + "))";
        }
        NetworkConnector connector = new DiscoveryNetworkConnector(new URI(uri));
        connector.setName("to-" + remoteBroker.getBrokerName());
        connector.setDynamicOnly(dynamicOnly);
        connector.setNetworkTTL(networkTTL);
        connector.setConduitSubscriptions(conduit);
        localBroker.addNetworkConnector(connector);
        maxSetupTime = 2000;
        return connector;
    } else {
        throw new Exception("Remote broker has no registered connectors.");
    }
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkConnector(org.apache.activemq.network.NetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) URI(java.net.URI) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) TimeoutException(java.util.concurrent.TimeoutException) JMSException(javax.jms.JMSException)

Example 3 with DiscoveryNetworkConnector

use of org.apache.activemq.network.DiscoveryNetworkConnector in project activemq-artemis by apache.

the class ThreeBrokerStompTemporaryQueueTest method bridgeBrokers.

@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
    List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
    URI remoteURI;
    if (!transportConnectors.isEmpty()) {
        remoteURI = transportConnectors.get(0).getConnectUri();
        NetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:" + remoteURI));
        connector.setName(localBroker.getBrokerName() + remoteBroker.getBrokerName());
        localBroker.addNetworkConnector(connector);
        maxSetupTime = 2000;
        return connector;
    } else {
        throw new Exception("Remote broker has no registered connectors.");
    }
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) NetworkConnector(org.apache.activemq.network.NetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) URI(java.net.URI) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) IOException(java.io.IOException)

Example 4 with DiscoveryNetworkConnector

use of org.apache.activemq.network.DiscoveryNetworkConnector in project activemq-artemis by apache.

the class BrokerQueueNetworkWithDisconnectTest method bridgeBrokers.

@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
    List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
    URI remoteURI;
    if (!transportConnectors.isEmpty()) {
        remoteURI = transportConnectors.get(0).getConnectUri();
        if (useSocketProxy) {
            socketProxy = new SocketProxy(remoteURI);
            remoteURI = socketProxy.getUrl();
        }
        DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI("static:(" + remoteURI + "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")?useExponentialBackOff=false"));
        connector.setDynamicOnly(dynamicOnly);
        connector.setNetworkTTL(networkTTL);
        localBroker.addNetworkConnector(connector);
        maxSetupTime = 2000;
        if (useDuplexNetworkBridge) {
            connector.setDuplex(true);
        }
        return connector;
    } else {
        throw new Exception("Remote broker has no registered connectors.");
    }
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) SocketProxy(org.apache.activemq.util.SocketProxy) URI(java.net.URI) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector)

Example 5 with DiscoveryNetworkConnector

use of org.apache.activemq.network.DiscoveryNetworkConnector in project activemq-artemis by apache.

the class MulticastDiscoveryOnFaultyNetworkTest method bridgeBrokers.

@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean dynamicOnly, int networkTTL, boolean conduit, boolean failover) throws Exception {
    String networkDisoveryUrlString = useStaticDiscovery ? "static:(" + remoteBroker.getTransportConnectors().get(0).getPublishableConnectString() + ")?useExponentialBackOff=false" : "multicast://default?group=TESTERIC&useLocalHost=false";
    DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI(networkDisoveryUrlString));
    connector.setDynamicOnly(dynamicOnly);
    connector.setNetworkTTL(networkTTL);
    connector.setDuplex(useDuplexNetworkBridge);
    maxSetupTime = 2000;
    if (!useStaticDiscovery) {
        List<TransportConnector> transportConnectors = remoteBroker.getTransportConnectors();
        if (!transportConnectors.isEmpty()) {
            TransportConnector mCastTrpConnector = (transportConnectors.get(0));
            mCastTrpConnector.setDiscoveryUri(new URI("multicast://default?group=TESTERIC"));
        }
    }
    localBroker.addNetworkConnector(connector);
    return connector;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) URI(java.net.URI)

Aggregations

DiscoveryNetworkConnector (org.apache.activemq.network.DiscoveryNetworkConnector)9 URI (java.net.URI)8 TransportConnector (org.apache.activemq.broker.TransportConnector)6 NetworkConnector (org.apache.activemq.network.NetworkConnector)6 JMSException (javax.jms.JMSException)2 SocketProxy (org.apache.activemq.util.SocketProxy)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 TimeoutException (java.util.concurrent.TimeoutException)1 BrokerService (org.apache.activemq.broker.BrokerService)1 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)1 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)1 SystemUsage (org.apache.activemq.usage.SystemUsage)1