Search in sources :

Example 6 with ConnectionFactoryProperties

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

the class ResourceAdapterTest method testCreateConnectionFactoryOverrideConnector.

@Test
public void testCreateConnectionFactoryOverrideConnector() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(InVMConnectorFactory.class.getName());
    ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
    ArrayList<String> value = new ArrayList<>();
    value.add(NettyConnectorFactory.class.getName());
    connectionFactoryProperties.setParsedConnectorClassNames(value);
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
    ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
    Assert.assertNotSame(factory, defaultFactory);
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory) ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) NettyConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory) ArrayList(java.util.ArrayList) ActiveMQResourceAdapter(org.apache.activemq.artemis.ra.ActiveMQResourceAdapter) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) Test(org.junit.Test)

Example 7 with ConnectionFactoryProperties

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

the class ResourceAdapterTest method testCreateConnectionFactoryOverrideDiscovery.

@Test
public void testCreateConnectionFactoryOverrideDiscovery() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(InVMConnectorFactory.class.getName());
    ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
    connectionFactoryProperties.setDiscoveryAddress("myhost");
    connectionFactoryProperties.setDiscoveryPort(5678);
    connectionFactoryProperties.setDiscoveryLocalBindAddress("newAddress");
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
    ActiveMQConnectionFactory defaultFactory = ra.getDefaultActiveMQConnectionFactory();
    Assert.assertNotSame(factory, defaultFactory);
    DiscoveryGroupConfiguration dc = factory.getServerLocator().getDiscoveryGroupConfiguration();
    UDPBroadcastEndpointFactory udpDg = (UDPBroadcastEndpointFactory) dc.getBroadcastEndpointFactory();
    Assert.assertEquals(udpDg.getLocalBindAddress(), "newAddress");
    Assert.assertEquals(udpDg.getGroupAddress(), "myhost");
    Assert.assertEquals(udpDg.getGroupPort(), 5678);
}
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) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) UDPBroadcastEndpointFactory(org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory) Test(org.junit.Test)

Example 8 with ConnectionFactoryProperties

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

the class ConnectionFactoryPropertiesTest method testInequality2.

@Test
public void testInequality2() throws Exception {
    ConnectionFactoryProperties cfp1 = new ConnectionFactoryProperties();
    List<String> connectorClassNames1 = new ArrayList<>();
    connectorClassNames1.add("myConnector");
    cfp1.setParsedConnectorClassNames(connectorClassNames1);
    List<Map<String, Object>> connectionParameters1 = new ArrayList<>();
    Map<String, Object> params1 = new HashMap<>();
    params1.put("port", "0");
    connectionParameters1.add(params1);
    cfp1.setParsedConnectionParameters(connectionParameters1);
    cfp1.setAutoGroup(true);
    ConnectionFactoryProperties cfp2 = new ConnectionFactoryProperties();
    List<String> connectorClassNames2 = new ArrayList<>();
    connectorClassNames2.add("myConnector2");
    cfp2.setParsedConnectorClassNames(connectorClassNames2);
    List<Map<String, Object>> connectionParameters2 = new ArrayList<>();
    Map<String, Object> params2 = new HashMap<>();
    params2.put("port", "0");
    connectionParameters2.add(params2);
    cfp2.setParsedConnectionParameters(connectionParameters2);
    cfp2.setAutoGroup(true);
    assertFalse(cfp1.equals(cfp2));
}
Also used : ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 9 with ConnectionFactoryProperties

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

the class ConnectionFactoryPropertiesTest method testInequality.

@Test
public void testInequality() throws Exception {
    ConnectionFactoryProperties cfp1 = new ConnectionFactoryProperties();
    List<String> connectorClassNames1 = new ArrayList<>();
    connectorClassNames1.add("myConnector");
    cfp1.setParsedConnectorClassNames(connectorClassNames1);
    List<Map<String, Object>> connectionParameters1 = new ArrayList<>();
    Map<String, Object> params1 = new HashMap<>();
    params1.put("port", "0");
    connectionParameters1.add(params1);
    cfp1.setParsedConnectionParameters(connectionParameters1);
    cfp1.setAutoGroup(true);
    ConnectionFactoryProperties cfp2 = new ConnectionFactoryProperties();
    List<String> connectorClassNames2 = new ArrayList<>();
    connectorClassNames2.add("myConnector");
    cfp2.setParsedConnectorClassNames(connectorClassNames2);
    List<Map<String, Object>> connectionParameters2 = new ArrayList<>();
    Map<String, Object> params2 = new HashMap<>();
    params2.put("port", "1");
    connectionParameters2.add(params2);
    cfp2.setParsedConnectionParameters(connectionParameters2);
    cfp2.setAutoGroup(true);
    assertFalse(cfp1.equals(cfp2));
}
Also used : ConnectionFactoryProperties(org.apache.activemq.artemis.ra.ConnectionFactoryProperties) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) Test(org.junit.Test)

Example 10 with ConnectionFactoryProperties

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

the class ResourceAdapterTest method testCreateConnectionFactoryOverrides.

@Test
public void testCreateConnectionFactoryOverrides() throws Exception {
    ActiveMQResourceAdapter ra = new ActiveMQResourceAdapter();
    ra.setConnectorClassName(InVMConnectorFactory.class.getName());
    ConnectionFactoryProperties connectionFactoryProperties = new ConnectionFactoryProperties();
    connectionFactoryProperties.setAutoGroup(!ActiveMQClient.DEFAULT_AUTO_GROUP);
    connectionFactoryProperties.setBlockOnAcknowledge(!ActiveMQClient.DEFAULT_BLOCK_ON_ACKNOWLEDGE);
    connectionFactoryProperties.setBlockOnNonDurableSend(!ActiveMQClient.DEFAULT_BLOCK_ON_NON_DURABLE_SEND);
    connectionFactoryProperties.setBlockOnDurableSend(!ActiveMQClient.DEFAULT_BLOCK_ON_DURABLE_SEND);
    connectionFactoryProperties.setCallTimeout(1L);
    connectionFactoryProperties.setClientFailureCheckPeriod(2L);
    connectionFactoryProperties.setClientID("myid");
    connectionFactoryProperties.setConnectionLoadBalancingPolicyClassName("mlbcn");
    connectionFactoryProperties.setConnectionTTL(3L);
    connectionFactoryProperties.setConsumerMaxRate(4);
    connectionFactoryProperties.setConsumerWindowSize(5);
    connectionFactoryProperties.setDiscoveryInitialWaitTimeout(6L);
    connectionFactoryProperties.setDiscoveryRefreshTimeout(7L);
    connectionFactoryProperties.setDupsOKBatchSize(8);
    connectionFactoryProperties.setMinLargeMessageSize(10);
    connectionFactoryProperties.setPreAcknowledge(!ActiveMQClient.DEFAULT_PRE_ACKNOWLEDGE);
    connectionFactoryProperties.setProducerMaxRate(11);
    connectionFactoryProperties.setConfirmationWindowSize(12);
    connectionFactoryProperties.setReconnectAttempts(13);
    connectionFactoryProperties.setRetryInterval(14L);
    connectionFactoryProperties.setRetryIntervalMultiplier(15d);
    connectionFactoryProperties.setScheduledThreadPoolMaxSize(16);
    connectionFactoryProperties.setThreadPoolMaxSize(17);
    connectionFactoryProperties.setTransactionBatchSize(18);
    connectionFactoryProperties.setUseGlobalPools(!ActiveMQClient.DEFAULT_USE_GLOBAL_POOLS);
    ActiveMQConnectionFactory factory = ra.getConnectionFactory(connectionFactoryProperties);
    Assert.assertEquals(factory.getCallTimeout(), 1);
    Assert.assertEquals(factory.getClientFailureCheckPeriod(), 2);
    Assert.assertEquals(factory.getClientID(), "myid");
    Assert.assertEquals(factory.getConnectionLoadBalancingPolicyClassName(), "mlbcn");
    Assert.assertEquals(factory.getConnectionTTL(), 3);
    Assert.assertEquals(factory.getConsumerMaxRate(), 4);
    Assert.assertEquals(factory.getConsumerWindowSize(), 5);
    Assert.assertEquals(factory.getDupsOKBatchSize(), 8);
    Assert.assertEquals(factory.getMinLargeMessageSize(), 10);
    Assert.assertEquals(factory.getProducerMaxRate(), 11);
    Assert.assertEquals(factory.getConfirmationWindowSize(), 12);
    Assert.assertEquals(factory.getReconnectAttempts(), 13);
    Assert.assertEquals(factory.getRetryInterval(), 14);
    Assert.assertEquals(factory.getRetryIntervalMultiplier(), 15d, 0.000001);
    Assert.assertEquals(factory.getScheduledThreadPoolMaxSize(), 16);
    Assert.assertEquals(factory.getThreadPoolMaxSize(), 17);
    Assert.assertEquals(factory.getTransactionBatchSize(), 18);
    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)

Aggregations

ConnectionFactoryProperties (org.apache.activemq.artemis.ra.ConnectionFactoryProperties)13 Test (org.junit.Test)13 ActiveMQResourceAdapter (org.apache.activemq.artemis.ra.ActiveMQResourceAdapter)10 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)9 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)4 Map (java.util.Map)4 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)4 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)4 DiscoveryGroupConfiguration (org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration)1 UDPBroadcastEndpointFactory (org.apache.activemq.artemis.api.core.UDPBroadcastEndpointFactory)1 NettyConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory)1 ActiveMQServer (org.apache.activemq.artemis.core.server.ActiveMQServer)1