Search in sources :

Example 21 with TransportConnector

use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.

the class FailoverClusterTestSupport method addTransportConnector.

protected void addTransportConnector(BrokerService brokerService, String connectorName, String uri, boolean clustered) throws Exception {
    TransportConnector connector = brokerService.addConnector(uri);
    connector.setName(connectorName);
    if (clustered) {
        connector.setRebalanceClusterClients(true);
        connector.setUpdateClusterClients(true);
        connector.setUpdateClusterClientsOnRemove(true);
    } else {
        connector.setRebalanceClusterClients(false);
        connector.setUpdateClusterClients(false);
        connector.setUpdateClusterClientsOnRemove(false);
    }
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector)

Example 22 with TransportConnector

use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.

the class DiscoveryTransportNoBrokerTest method testNoExtraThreads.

public void testNoExtraThreads() throws Exception {
    BrokerService broker = new BrokerService();
    TransportConnector tcp = broker.addConnector("tcp://localhost:0?transport.closeAsync=false");
    String group = "GR-" + System.currentTimeMillis();
    URI discoveryUri = new URI("multicast://default?group=" + group);
    tcp.setDiscoveryUri(discoveryUri);
    broker.start();
    broker.waitUntilStarted();
    Vector<String> existingNames = new Vector<>();
    Thread[] threads = getThreads();
    for (Thread t : threads) {
        existingNames.add(t.getName());
    }
    final int idleThreadCount = threads.length;
    LOG.info("Broker started - thread Count:" + idleThreadCount);
    final int noConnectionToCreate = 10;
    for (int i = 0; i < 10; i++) {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("discovery:(multicast://239.255.2.3:6155?group=" + group + ")?closeAsync=false&startupMaxReconnectAttempts=10&initialReconnectDelay=1000");
        LOG.info("Connecting.");
        Connection connection = factory.createConnection();
        connection.setClientID("test");
        connection.close();
    }
    Thread.sleep(2000);
    threads = getThreads();
    for (Thread t : threads) {
        if (!existingNames.contains(t.getName())) {
            LOG.info("Remaining thread:" + t);
        }
    }
    assertTrue("no extra threads per connection", Thread.activeCount() - idleThreadCount < noConnectionToCreate);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) Connection(javax.jms.Connection) BrokerService(org.apache.activemq.broker.BrokerService) URI(java.net.URI) Vector(java.util.Vector)

Example 23 with TransportConnector

use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.

the class NIOSSLBasicTest method createBroker.

public BrokerService createBroker(String connectorName, String connectorString) throws Exception {
    BrokerService broker = new BrokerService();
    broker.setPersistent(false);
    broker.setUseJmx(false);
    TransportConnector connector = broker.addConnector(connectorString);
    connector.setName(connectorName);
    broker.start();
    broker.waitUntilStarted();
    return broker;
}
Also used : TransportConnector(org.apache.activemq.broker.TransportConnector) BrokerService(org.apache.activemq.broker.BrokerService)

Example 24 with TransportConnector

use of org.apache.activemq.broker.TransportConnector in project activemq-artemis by apache.

the class NIOSSLLoadTest method setUp.

@Override
protected void setUp() throws Exception {
    System.setProperty("javax.net.ssl.trustStore", TRUST_KEYSTORE);
    System.setProperty("javax.net.ssl.trustStorePassword", PASSWORD);
    System.setProperty("javax.net.ssl.trustStoreType", KEYSTORE_TYPE);
    System.setProperty("javax.net.ssl.keyStore", SERVER_KEYSTORE);
    System.setProperty("javax.net.ssl.keyStoreType", KEYSTORE_TYPE);
    System.setProperty("javax.net.ssl.keyStorePassword", PASSWORD);
    broker = new BrokerService();
    broker.setPersistent(false);
    broker.setUseJmx(false);
    TransportConnector connector = broker.addConnector("nio+ssl://localhost:0?transport.needClientAuth=true&transport.enabledCipherSuites=SSL_RSA_WITH_RC4_128_SHA,SSL_DH_anon_WITH_3DES_EDE_CBC_SHA");
    broker.start();
    broker.waitUntilStarted();
    ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("nio+ssl://localhost:" + connector.getConnectUri().getPort());
    connection = factory.createConnection();
    session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    connection.start();
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) TransportConnector(org.apache.activemq.broker.TransportConnector) BrokerService(org.apache.activemq.broker.BrokerService)

Example 25 with TransportConnector

use of org.apache.activemq.broker.TransportConnector 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)

Aggregations

TransportConnector (org.apache.activemq.broker.TransportConnector)59 URI (java.net.URI)31 BrokerService (org.apache.activemq.broker.BrokerService)31 NetworkConnector (org.apache.activemq.network.NetworkConnector)10 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)9 DiscoveryNetworkConnector (org.apache.activemq.network.DiscoveryNetworkConnector)7 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)4 Connection (javax.jms.Connection)4 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)4 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)4 JMSException (javax.jms.JMSException)3 Session (javax.jms.Session)3 File (java.io.File)2 Principal (java.security.Principal)2 MessageProducer (javax.jms.MessageProducer)2 ActiveMQMessageConsumer (org.apache.activemq.ActiveMQMessageConsumer)2 ConnectionContext (org.apache.activemq.broker.ConnectionContext)2 Connector (org.apache.activemq.broker.Connector)2 StubConnection (org.apache.activemq.broker.StubConnection)2