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);
}
}
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);
}
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;
}
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();
}
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.");
}
}
Aggregations