use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class NonHATopologyTest method internalTest.
public void internalTest(boolean isNetty) throws Exception {
ActiveMQServer server = null;
ServerLocatorInternal locator = null;
try {
server = createServer(false, isNetty);
if (!isNetty) {
server.getConfiguration().getAcceptorConfigurations().add(new TransportConfiguration(NETTY_ACCEPTOR_FACTORY));
server.getConfiguration().getConnectorConfigurations().put("netty", new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
ArrayList<String> list = new ArrayList<>();
list.add("netty");
Configuration config = server.getConfiguration();
config.getClusterConfigurations().add(new ClusterConnectionConfiguration().setName("tst").setAddress("jms").setConnectorName("netty").setRetryInterval(1000).setConfirmationWindowSize(1000).setMessageLoadBalancingType(MessageLoadBalancingType.ON_DEMAND).setStaticConnectors(list).setAllowDirectConnectionsOnly(true));
}
server.start();
locator = (ServerLocatorInternal) createNonHALocator(isNetty);
ClientSessionFactory factory = createSessionFactory(locator);
Topology topology = locator.getTopology();
assertEquals(1, topology.getMembers().size());
factory.close();
TopologyMemberImpl member = topology.getMembers().iterator().next();
if (isNetty) {
assertEquals(NettyConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
} else {
assertEquals(InVMConnectorFactory.class.getName(), member.getLive().getFactoryClassName());
}
} finally {
try {
locator.close();
} catch (Exception ignored) {
}
try {
server.stop();
} catch (Exception ignored) {
}
server = null;
locator = null;
}
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ServerLocatorConnectTest method testMultipleConnectorSingleServerConnect.
@Test
public void testMultipleConnectorSingleServerConnect() throws Exception {
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())));
ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
assertEquals(csf.numConnections(), 1);
locator.close();
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ServerLocatorConnectTest method testSingleConnectorSingleServerConnect.
@Test
public void testSingleConnectorSingleServerConnect() throws Exception {
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())));
ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
assertEquals(csf.numConnections(), 1);
locator.close();
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ServerLocatorConnectTest method testMultipleConnectorSingleServerNoConnectAttemptReconnect.
@Test
public void testMultipleConnectorSingleServerNoConnectAttemptReconnect() throws Exception {
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(5, isNetty())));
locator.setReconnectAttempts(15);
CountDownLatch countDownLatch = new CountDownLatch(1);
Connector target = new Connector(locator, countDownLatch);
Thread t = new Thread(target);
t.start();
// let them get started
Thread.sleep(500);
locator.close();
assertTrue(countDownLatch.await(5, TimeUnit.SECONDS));
assertNull(target.csf);
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorInternal in project activemq-artemis by apache.
the class ServerLocatorConnectTest method testMultipleConnectorSingleServerConnectReconnect.
@Test
public void testMultipleConnectorSingleServerConnectReconnect() throws Exception {
ServerLocatorInternal locator = (ServerLocatorInternal) ActiveMQClient.createServerLocatorWithoutHA(createTransportConfiguration(isNetty(), false, generateParams(0, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(1, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(2, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(3, isNetty())), createTransportConfiguration(isNetty(), false, generateParams(4, isNetty())));
locator.setReconnectAttempts(15);
ClientSessionFactoryInternal csf = locator.connect();
assertNotNull(csf);
assertEquals(csf.numConnections(), 1);
locator.close();
}
Aggregations