Search in sources :

Example 6 with ServerLocatorImpl

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);
        }
    }
}
Also used : ClusterController(org.apache.activemq.artemis.core.server.cluster.ClusterController) ActiveMQClusterSecurityException(org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) ActiveMQClusterSecurityException(org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException) ClusterControl(org.apache.activemq.artemis.core.server.cluster.ClusterControl) Test(org.junit.Test)

Example 7 with ServerLocatorImpl

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);
}
Also used : ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl)

Example 8 with ServerLocatorImpl

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);
}
Also used : ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl)

Example 9 with ServerLocatorImpl

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();
}
Also used : MessageEndpointFactory(org.apache.activemq.artemis.tests.unit.ra.MessageEndpointFactory) ActiveMQActivation(org.apache.activemq.artemis.ra.inflow.ActiveMQActivation) Connection(javax.jms.Connection) XARecoveryConfig(org.apache.activemq.artemis.service.extensions.xa.recovery.XARecoveryConfig) BootstrapContext(org.apache.activemq.artemis.tests.unit.ra.BootstrapContext) MessageEndpoint(javax.resource.spi.endpoint.MessageEndpoint) ActiveMQDestination(org.apache.activemq.artemis.jms.client.ActiveMQDestination) ClientSession(org.apache.activemq.artemis.api.core.client.ClientSession) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) ClientSessionFactory(org.apache.activemq.artemis.api.core.client.ClientSessionFactory) ActiveMQActivationSpec(org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec) ServerLocator(org.apache.activemq.artemis.api.core.client.ServerLocator) Test(org.junit.Test)

Example 10 with ServerLocatorImpl

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();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) BeforeClass(org.junit.BeforeClass)

Aggregations

ServerLocatorImpl (org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl)11 Test (org.junit.Test)6 ServerLocator (org.apache.activemq.artemis.api.core.client.ServerLocator)3 Field (java.lang.reflect.Field)2 Method (java.lang.reflect.Method)2 HashMap (java.util.HashMap)2 ScheduledThreadPoolExecutor (java.util.concurrent.ScheduledThreadPoolExecutor)2 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)2 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)2 ClusterControl (org.apache.activemq.artemis.core.server.cluster.ClusterControl)2 ClusterController (org.apache.activemq.artemis.core.server.cluster.ClusterController)2 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)2 URI (java.net.URI)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Connection (javax.jms.Connection)1 MessageEndpoint (javax.resource.spi.endpoint.MessageEndpoint)1 ActiveMQClusterSecurityException (org.apache.activemq.artemis.api.core.ActiveMQClusterSecurityException)1 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)1