Search in sources :

Example 6 with DiscoveryNetworkConnector

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

the class NetworkAsyncStartTest method bridgeBroker.

private void bridgeBroker(BrokerService localBroker, String remoteURI) throws Exception {
    String uri = "static:(" + remoteURI + ")";
    NetworkConnector connector = new DiscoveryNetworkConnector(new URI(uri));
    connector.setName("bridge-" + bridgeCount++);
    localBroker.addNetworkConnector(connector);
}
Also used : NetworkConnector(org.apache.activemq.network.NetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) URI(java.net.URI)

Example 7 with DiscoveryNetworkConnector

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

the class DurableSubInBrokerNetworkTest method setUp.

@Override
protected void setUp() throws Exception {
    useJmx = true;
    super.setUp();
    URI ncUri = new URI("static:(" + connector.getConnectUri().toString() + ")");
    NetworkConnector nc = new DiscoveryNetworkConnector(ncUri);
    nc.setDuplex(true);
    remoteBroker.addNetworkConnector(nc);
    nc.start();
}
Also used : NetworkConnector(org.apache.activemq.network.NetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) URI(java.net.URI) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector)

Example 8 with DiscoveryNetworkConnector

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

the class DurableSubscriberWithNetworkDisconnectTest method bridgeBrokers.

@Override
protected NetworkConnector bridgeBrokers(BrokerService localBroker, BrokerService remoteBroker, boolean l_dynamicOnly, int networkTTL, boolean l_conduit, boolean l_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();
        }
        String options = "";
        if (failover) {
            options = "static:(failover:(" + remoteURI;
        } else {
            options = "static:(" + remoteURI;
        }
        if (inactivity) {
            options += "?wireFormat.maxInactivityDuration=" + inactiveDuration + "&wireFormat.maxInactivityDurationInitalDelay=" + inactiveDuration + ")";
        } else {
            options += ")";
        }
        if (failover) {
            options += "?maxReconnectAttempts=0)";
        }
        options += "?useExponentialBackOff=" + exponentialBackOff;
        DiscoveryNetworkConnector connector = new DiscoveryNetworkConnector(new URI(options));
        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) JMSException(javax.jms.JMSException)

Example 9 with DiscoveryNetworkConnector

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

the class AMQStackOverFlowTest method createBrokerService.

private BrokerService createBrokerService(final String brokerName, final String uri1, final String uri2) throws Exception {
    final BrokerService brokerService = new BrokerService();
    brokerService.setBrokerName(brokerName);
    brokerService.setPersistent(false);
    brokerService.setUseJmx(true);
    final SystemUsage memoryManager = new SystemUsage();
    // memoryManager.getMemoryUsage().setLimit(10);
    brokerService.setSystemUsage(memoryManager);
    final List<PolicyEntry> policyEntries = new ArrayList<>();
    final PolicyEntry entry = new PolicyEntry();
    entry.setQueue(">");
    // entry.setMemoryLimit(1);
    policyEntries.add(entry);
    final PolicyMap policyMap = new PolicyMap();
    policyMap.setPolicyEntries(policyEntries);
    brokerService.setDestinationPolicy(policyMap);
    final TransportConnector tConnector = new TransportConnector();
    tConnector.setUri(new URI(uri1));
    tConnector.setName(brokerName + ".transportConnector");
    brokerService.addConnector(tConnector);
    if (uri2 != null) {
        final NetworkConnector nc = new DiscoveryNetworkConnector(new URI("static:" + uri2));
        nc.setBridgeTempDestinations(true);
        nc.setBrokerName(brokerName);
        // nc.setPrefetchSize(1);
        brokerService.addNetworkConnector(nc);
    }
    return brokerService;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) ArrayList(java.util.ArrayList) SystemUsage(org.apache.activemq.usage.SystemUsage) NetworkConnector(org.apache.activemq.network.NetworkConnector) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) URI(java.net.URI) DiscoveryNetworkConnector(org.apache.activemq.network.DiscoveryNetworkConnector)

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