Search in sources :

Example 26 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory in project activemq-artemis by apache.

the class ConsumerTest method createFactory.

private ConnectionFactory createFactory(int protocol) {
    switch(protocol) {
        case // core protocol
        1:
            // core protocol
            ActiveMQConnectionFactory coreCF = new ActiveMQConnectionFactory();
            coreCF.setCompressLargeMessage(true);
            coreCF.setMinLargeMessageSize(10 * 1024);
            return coreCF;
        // amqp
        case 2:
            return new JmsConnectionFactory("amqp://localhost:61616");
        // openwire
        case 3:
            return new org.apache.activemq.ActiveMQConnectionFactory("tcp://localhost:61616");
        default:
            return null;
    }
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) JmsConnectionFactory(org.apache.qpid.jms.JmsConnectionFactory)

Example 27 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory 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 28 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory 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 29 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory 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 30 with ActiveMQConnectionFactory

use of org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory 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

ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)221 Test (org.junit.Test)141 Connection (javax.jms.Connection)84 Session (javax.jms.Session)84 MessageProducer (javax.jms.MessageProducer)63 MessageConsumer (javax.jms.MessageConsumer)60 TextMessage (javax.jms.TextMessage)49 Queue (javax.jms.Queue)48 ConnectionFactory (javax.jms.ConnectionFactory)35 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)27 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)26 ClientSession (org.apache.activemq.artemis.api.core.client.ClientSession)24 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)24 URI (java.net.URI)22 JMSException (javax.jms.JMSException)20 Message (javax.jms.Message)19 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)19 InitialContext (javax.naming.InitialContext)16 Context (javax.naming.Context)15 Hashtable (java.util.Hashtable)14