Search in sources :

Example 1 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testCreateConnectionFactoryNoOverrides.

@Test
public void testCreateConnectionFactoryNoOverrides() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(InVMConnectorFactory.class.getName());
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
    Assert.assertEquals(factory.getCallTimeout(), ActiveMQClient.DEFAULT_CALL_TIMEOUT);
    Assert.assertEquals(factory.getClientFailureCheckPeriod(), ActiveMQClient.DEFAULT_CLIENT_FAILURE_CHECK_PERIOD);
    Assert.assertEquals(factory.getClientID(), null);
    Assert.assertEquals(factory.getConnectionLoadBalancingPolicyClassName(), ActiveMQClient.DEFAULT_CONNECTION_LOAD_BALANCING_POLICY_CLASS_NAME);
    Assert.assertEquals(factory.getConnectionTTL(), ActiveMQClient.DEFAULT_CONNECTION_TTL);
    Assert.assertEquals(factory.getConsumerMaxRate(), ActiveMQClient.DEFAULT_CONSUMER_MAX_RATE);
    Assert.assertEquals(factory.getConsumerWindowSize(), ActiveMQClient.DEFAULT_CONSUMER_WINDOW_SIZE);
    Assert.assertEquals(factory.getDupsOKBatchSize(), ActiveMQClient.DEFAULT_ACK_BATCH_SIZE);
    Assert.assertEquals(factory.getMinLargeMessageSize(), ActiveMQClient.DEFAULT_MIN_LARGE_MESSAGE_SIZE);
    Assert.assertEquals(factory.getProducerMaxRate(), ActiveMQClient.DEFAULT_PRODUCER_MAX_RATE);
    Assert.assertEquals(factory.getConfirmationWindowSize(), ActiveMQClient.DEFAULT_CONFIRMATION_WINDOW_SIZE);
    // by default, reconnect attempts is set to -1
    Assert.assertEquals(-1, factory.getReconnectAttempts());
    Assert.assertEquals(factory.getRetryInterval(), ActiveMQClient.DEFAULT_RETRY_INTERVAL);
    Assert.assertEquals(factory.getRetryIntervalMultiplier(), ActiveMQClient.DEFAULT_RETRY_INTERVAL_MULTIPLIER, 0.000001);
    Assert.assertEquals(factory.getScheduledThreadPoolMaxSize(), ActiveMQClient.DEFAULT_SCHEDULED_THREAD_POOL_MAX_SIZE);
    Assert.assertEquals(factory.getThreadPoolMaxSize(), ActiveMQClient.DEFAULT_THREAD_POOL_MAX_SIZE);
    Assert.assertEquals(factory.getTransactionBatchSize(), ActiveMQClient.DEFAULT_ACK_BATCH_SIZE);
    Assert.assertEquals(factory.isAutoGroup(), ActiveMQClient.DEFAULT_AUTO_GROUP);
    Assert.assertEquals(factory.isBlockOnAcknowledge(), ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE);
    Assert.assertEquals(factory.isBlockOnNonDurableSend(), ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND);
    Assert.assertEquals(factory.isBlockOnDurableSend(), ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND);
    Assert.assertEquals(factory.isPreAcknowledge(), ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE);
    Assert.assertEquals(factory.isUseGlobalPools(), ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) Test(org.junit.Test)

Example 2 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testCreateConnectionFactoryThrowsException.

@Test
public void testCreateConnectionFactoryThrowsException() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
    try {
        ra.getConnectionFactory(connectionFactoryProperties);
        Assert.fail("should throw exception");
    } catch (IllegalArgumentException e) {
    // pass
    }
}
Also used : ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) Test(org.junit.Test)

Example 3 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testCreateConnectionFactoryMultipleConnectors.

@Test
public void testCreateConnectionFactoryMultipleConnectors() {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
    TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
    assertNotNull(configurations);
    assertEquals(3, configurations.length);
    assertEquals(NETTY_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
    assertEquals(2, configurations[0].getParams().size());
    assertEquals(INVM_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
    assertEquals(1, configurations[1].getParams().size());
    assertEquals(NETTY_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
    assertEquals(2, configurations[2].getParams().size());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Test(org.junit.Test)

Example 4 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method testCreateConnectionFactoryMultipleConnectorsAndParams.

@Test
public void testCreateConnectionFactoryMultipleConnectorsAndParams() {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(NETTY_CONNECTOR_FACTORY + "," + INVM_CONNECTOR_FACTORY + "," + NETTY_CONNECTOR_FACTORY);
    ra.setConnectionParameters("host=host1;port=61616, serverid=0, host=host2;port=61617");
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(new ConnectionFactoryProperties());
    TransportConfiguration[] configurations = factory.getServerLocator().getStaticTransportConfigurations();
    assertNotNull(configurations);
    assertEquals(3, configurations.length);
    assertEquals(NETTY_CONNECTOR_FACTORY, configurations[0].getFactoryClassName());
    assertEquals(2, configurations[0].getParams().size());
    assertEquals("host1", configurations[0].getParams().get("host"));
    assertEquals("61616", configurations[0].getParams().get("port"));
    assertEquals(INVM_CONNECTOR_FACTORY, configurations[1].getFactoryClassName());
    assertEquals(1, configurations[1].getParams().size());
    assertEquals("0", configurations[1].getParams().get("serverid"));
    assertEquals(NETTY_CONNECTOR_FACTORY, configurations[2].getFactoryClassName());
    assertEquals(2, configurations[2].getParams().size());
    assertEquals("host2", configurations[2].getParams().get("host"));
    assertEquals("61617", configurations[2].getParams().get("port"));
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Test(org.junit.Test)

Example 5 with ActiveMQResourceAdapter

use of org.apache.activemq.artemis.ra.ActiveMQResourceAdapter in project activemq-artemis by apache.

the class ResourceAdapterTest method test2DefaultConnectionFactorySame.

@Test
public void test2DefaultConnectionFactorySame() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(InVMConnectorFactory.class.getName());
    ActiveMQConnectionFactory factory = ra.getDefaultActiveMQConnectionFactory();
    ActiveMQConnectionFactory factory2 = ra.getDefaultActiveMQConnectionFactory();
    Assert.assertEquals(factory, factory2);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) Test(org.junit.Test)

Aggregations

ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)81 Test (org.junit.Test)72 ActiveMQActivationSpec (org.apache.activemq.artemis.ra.inflow.ActiveMQActivationSpec)54 CountDownLatch (java.util.concurrent.CountDownLatch)39 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)28 ClientMessage (org.apache.activemq.artemis.api.core.client.ClientMessage)24 ClientProducer (org.apache.activemq.artemis.api.core.client.ClientProducer)24 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)24 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)14 ConnectionFactoryProperties (org.apache.activemq.artemis.ra.ConnectionFactoryProperties)10 ActiveMQRAManagedConnectionFactory (org.apache.activemq.artemis.ra.ActiveMQRAManagedConnectionFactory)9 ActiveMQRAConnectionFactoryImpl (org.apache.activemq.artemis.ra.ActiveMQRAConnectionFactoryImpl)8 Binding (org.apache.activemq.artemis.core.postoffice.Binding)7 HashSet (java.util.HashSet)5 ClientSessionFactory (org.apache.activemq.artemis.api.core.client.ClientSessionFactory)5 Role (org.apache.activemq.artemis.core.security.Role)5 ActiveMQActivation (org.apache.activemq.artemis.ra.inflow.ActiveMQActivation)5 Before (org.junit.Before)5 ArrayList (java.util.ArrayList)4 Session (javax.jms.Session)4