use of org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl in project activemq-artemis by apache.
the class ClusterControllerTest method controlWithDifferentPassword.
@Test
public void controlWithDifferentPassword() throws Exception {
try (ServerLocatorImpl locator = (ServerLocatorImpl) createInVMNonHALocator()) {
locator.setProtocolManagerFactory(ActiveMQServerSideProtocolManagerFactory.getInstance(locator));
ClusterController controller = new ClusterController(getServer(1), getServer(1).getScheduledPool());
ClusterControl clusterControl = controller.connectToNodeInCluster((ClientSessionFactoryInternal) locator.createSessionFactory());
try {
clusterControl.authorize();
fail("should throw ActiveMQClusterSecurityException");
} catch (Exception e) {
assertTrue("should throw ActiveMQClusterSecurityException", e instanceof ActiveMQClusterSecurityException);
}
}
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl in project activemq-artemis by apache.
the class ClusterController method addClusterConnection.
/**
* add a locator for a cluster connection.
*
* @param name the cluster connection name
* @param dg the discovery group to use
* @param config the cluster connection config
*/
public void addClusterConnection(SimpleString name, DiscoveryGroupConfiguration dg, ClusterConnectionConfiguration config) {
ServerLocatorImpl serverLocator = (ServerLocatorImpl) ActiveMQClient.createServerLocatorWithHA(dg);
configAndAdd(name, serverLocator, config);
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl in project activemq-artemis by apache.
the class ClusterController method addClusterConnection.
/**
* add a locator for a cluster connection.
*
* @param name the cluster connection name
* @param tcConfigs the transport configurations to use
*/
public void addClusterConnection(SimpleString name, TransportConfiguration[] tcConfigs, ClusterConnectionConfiguration config) {
ServerLocatorImpl serverLocator = (ServerLocatorImpl) ActiveMQClient.createServerLocatorWithHA(tcConfigs);
configAndAdd(name, serverLocator, config);
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl in project activemq-artemis by apache.
the class ResourceAdapterTest method testStartStopActivationManyTimes.
@Test
public void testStartStopActivationManyTimes() throws Exception {
ServerLocator locator = createInVMNonHALocator();
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession(false, false, false);
ActiveMQDestination queue = (ActiveMQDestination) ActiveMQJMSClient.createQueue("test");
session.createQueue(queue.getSimpleAddress(), queue.getSimpleAddress(), true);
session.close();
ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
ra.setConnectorClassName(INVM_CONNECTOR_FACTORY);
ra.setUserName("userGlobal");
ra.setPassword("passwordGlobal");
ra.start(new BootstrapContext());
Connection conn = ra.getDefaultActiveMQConnectionFactory().createConnection();
conn.close();
ActiveMQActivationSpec spec = new ActiveMQActivationSpec();
spec.setResourceAdapter(ra);
spec.setUseJNDI(false);
spec.setUser("user");
spec.setPassword("password");
spec.setDestinationType("javax.jms.Topic");
spec.setDestination("test");
spec.setMinSession(1);
spec.setMaxSession(15);
ActiveMQActivation activation = new ActiveMQActivation(ra, new MessageEndpointFactory(), spec);
ServerLocatorImpl serverLocator = (ServerLocatorImpl) ra.getDefaultActiveMQConnectionFactory().getServerLocator();
Set<XARecoveryConfig> resources = ra.getRecoveryManager().getResources();
for (int i = 0; i < 10; i++) {
System.out.println(i);
activation.start();
assertEquals(1, resources.size());
activation.stop();
}
ra.stop();
assertEquals(0, resources.size());
locator.close();
}
use of org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl in project activemq-artemis by apache.
the class RawAckTest method setup.
@BeforeClass
public static void setup() throws Exception {
Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
activeMQServer.start();
HashMap<String, Object> transportConfig = new HashMap<>();
serverLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
sessionFactory = serverLocator.createSessionFactory();
consumerSessionFactory = serverLocator.createSessionFactory();
SimpleString addr = SimpleString.toSimpleString("testQueue");
activeMQServer.addAddressInfo(new AddressInfo(addr, RoutingType.MULTICAST));
activeMQServer.createQueue(addr, RoutingType.MULTICAST, addr, null, false, false);
session = sessionFactory.createSession(true, true);
producer = session.createProducer(addr);
session.start();
}
Aggregations