Search in sources :

Example 21 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project activemq-artemis by apache.

the class ManualReconnectionToSingleServerTest method setUp.

// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
@Override
@Before
public void setUp() throws Exception {
    super.setUp();
    context = new InVMNamingContext();
    server = createServer(false, createDefaultNettyConfig());
    JMSConfiguration configuration = new JMSConfigurationImpl();
    serverManager = new JMSServerManagerImpl(server, configuration);
    serverManager.setRegistry(new JndiBindingRegistry(context));
    configuration.getQueueConfigurations().add(new JMSQueueConfigurationImpl().setName(QUEUE_NAME).setBindings(QUEUE_NAME));
    ArrayList<TransportConfiguration> configs = new ArrayList<>();
    configs.add(new TransportConfiguration(NETTY_CONNECTOR_FACTORY));
    ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(registerConnectors(server, configs)).setBindings("/cf").setRetryInterval(1000).setReconnectAttempts(-1);
    configuration.getConnectionFactoryConfigurations().add(cfConfig);
    serverManager.start();
    listener = new Listener();
    exceptionLatch = new CountDownLatch(1);
    reconnectionLatch = new CountDownLatch(1);
    allMessagesReceived = new CountDownLatch(1);
}
Also used : JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) MessageListener(javax.jms.MessageListener) ExceptionListener(javax.jms.ExceptionListener) ArrayList(java.util.ArrayList) JndiBindingRegistry(org.apache.activemq.artemis.core.registry.JndiBindingRegistry) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) CountDownLatch(java.util.concurrent.CountDownLatch) JMSServerManagerImpl(org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) InVMNamingContext(org.apache.activemq.artemis.tests.unit.util.InVMNamingContext) Before(org.junit.Before)

Example 22 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project narayana by jbosstm.

the class JmsHelper method getConnectionFactoryConfiguration.

private ConnectionFactoryConfiguration getConnectionFactoryConfiguration() {
    ArrayList<String> connectorNames = new ArrayList<>();
    connectorNames.add("connector");
    return new ConnectionFactoryConfigurationImpl().setName(FACTORY_NAME).setConnectorNames(connectorNames).setBindings(FACTORY_NAME);
}
Also used : ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ArrayList(java.util.ArrayList)

Example 23 with ConnectionFactoryConfigurationImpl

use of org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl in project wildfly by wildfly.

the class ConnectionFactoryAdd method createConfiguration.

static ConnectionFactoryConfiguration createConfiguration(final OperationContext context, final String name, final ModelNode model) throws OperationFailedException {
    final List<String> entries = Common.ENTRIES.unwrap(context, model);
    final ConnectionFactoryConfiguration config = new ConnectionFactoryConfigurationImpl().setName(name).setHA(false).setBindings(entries.toArray(new String[entries.size()]));
    config.setHA(HA.resolveModelAttribute(context, model).asBoolean());
    config.setAutoGroup(Common.AUTO_GROUP.resolveModelAttribute(context, model).asBoolean());
    config.setBlockOnAcknowledge(Common.BLOCK_ON_ACKNOWLEDGE.resolveModelAttribute(context, model).asBoolean());
    config.setBlockOnDurableSend(Common.BLOCK_ON_DURABLE_SEND.resolveModelAttribute(context, model).asBoolean());
    config.setBlockOnNonDurableSend(Common.BLOCK_ON_NON_DURABLE_SEND.resolveModelAttribute(context, model).asBoolean());
    config.setCacheLargeMessagesClient(Common.CACHE_LARGE_MESSAGE_CLIENT.resolveModelAttribute(context, model).asBoolean());
    config.setCallTimeout(CALL_TIMEOUT.resolveModelAttribute(context, model).asLong());
    config.setClientFailureCheckPeriod(Common.CLIENT_FAILURE_CHECK_PERIOD.resolveModelAttribute(context, model).asInt());
    config.setCallFailoverTimeout(CALL_FAILOVER_TIMEOUT.resolveModelAttribute(context, model).asLong());
    final ModelNode clientId = CLIENT_ID.resolveModelAttribute(context, model);
    if (clientId.isDefined()) {
        config.setClientID(clientId.asString());
    }
    config.setCompressLargeMessages(Common.COMPRESS_LARGE_MESSAGES.resolveModelAttribute(context, model).asBoolean());
    config.setConfirmationWindowSize(Common.CONFIRMATION_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
    config.setConnectionTTL(Common.CONNECTION_TTL.resolveModelAttribute(context, model).asLong());
    List<String> connectorNames = Common.CONNECTORS.unwrap(context, model);
    config.setConnectorNames(connectorNames);
    config.setConsumerMaxRate(Common.CONSUMER_MAX_RATE.resolveModelAttribute(context, model).asInt());
    config.setConsumerWindowSize(Common.CONSUMER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
    final ModelNode discoveryGroupName = Common.DISCOVERY_GROUP.resolveModelAttribute(context, model);
    if (discoveryGroupName.isDefined()) {
        config.setDiscoveryGroupName(discoveryGroupName.asString());
    }
    config.setDupsOKBatchSize(Common.DUPS_OK_BATCH_SIZE.resolveModelAttribute(context, model).asInt());
    config.setFailoverOnInitialConnection(Common.FAILOVER_ON_INITIAL_CONNECTION.resolveModelAttribute(context, model).asBoolean());
    final ModelNode groupId = Common.GROUP_ID.resolveModelAttribute(context, model);
    if (groupId.isDefined()) {
        config.setGroupID(groupId.asString());
    }
    final ModelNode lbcn = Common.CONNECTION_LOAD_BALANCING_CLASS_NAME.resolveModelAttribute(context, model);
    if (lbcn.isDefined()) {
        config.setLoadBalancingPolicyClassName(lbcn.asString());
    }
    config.setMaxRetryInterval(Common.MAX_RETRY_INTERVAL.resolveModelAttribute(context, model).asLong());
    config.setMinLargeMessageSize(Common.MIN_LARGE_MESSAGE_SIZE.resolveModelAttribute(context, model).asInt());
    config.setPreAcknowledge(Common.PRE_ACKNOWLEDGE.resolveModelAttribute(context, model).asBoolean());
    config.setProducerMaxRate(Common.PRODUCER_MAX_RATE.resolveModelAttribute(context, model).asInt());
    config.setProducerWindowSize(Common.PRODUCER_WINDOW_SIZE.resolveModelAttribute(context, model).asInt());
    config.setReconnectAttempts(Common.RECONNECT_ATTEMPTS.resolveModelAttribute(context, model).asInt());
    config.setRetryInterval(Common.RETRY_INTERVAL.resolveModelAttribute(context, model).asLong());
    config.setRetryIntervalMultiplier(Common.RETRY_INTERVAL_MULTIPLIER.resolveModelAttribute(context, model).asDouble());
    config.setScheduledThreadPoolMaxSize(Common.SCHEDULED_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
    config.setThreadPoolMaxSize(Common.THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
    config.setTransactionBatchSize(Common.TRANSACTION_BATCH_SIZE.resolveModelAttribute(context, model).asInt());
    config.setUseGlobalPools(Common.USE_GLOBAL_POOLS.resolveModelAttribute(context, model).asBoolean());
    config.setLoadBalancingPolicyClassName(Common.CONNECTION_LOAD_BALANCING_CLASS_NAME.resolveModelAttribute(context, model).asString());
    final ModelNode clientProtocolManagerFactory = Common.PROTOCOL_MANAGER_FACTORY.resolveModelAttribute(context, model);
    if (clientProtocolManagerFactory.isDefined()) {
        config.setProtocolManagerFactoryStr(clientProtocolManagerFactory.asString());
    }
    List<String> deserializationBlackList = Common.DESERIALIZATION_BLACKLIST.unwrap(context, model);
    if (!deserializationBlackList.isEmpty()) {
        config.setDeserializationBlackList(String.join(",", deserializationBlackList));
    }
    List<String> deserializationWhiteList = Common.DESERIALIZATION_WHITELIST.unwrap(context, model);
    if (!deserializationWhiteList.isEmpty()) {
        config.setDeserializationWhiteList(String.join(",", deserializationWhiteList));
    }
    JMSFactoryType jmsFactoryType = ConnectionFactoryType.valueOf(ConnectionFactoryAttributes.Regular.FACTORY_TYPE.resolveModelAttribute(context, model).asString()).getType();
    config.setFactoryType(jmsFactoryType);
    config.setInitialMessagePacketSize(ConnectionFactoryAttributes.Common.INITIAL_MESSAGE_PACKET_SIZE.resolveModelAttribute(context, model).asInt());
    config.setEnableSharedClientID(true);
    config.setEnable1xPrefixes(true);
    config.setUseTopologyForLoadBalancing(ConnectionFactoryAttributes.Common.USE_TOPOLOGY.resolveModelAttribute(context, model).asBoolean());
    return config;
}
Also used : JMSFactoryType(org.apache.activemq.artemis.api.jms.JMSFactoryType) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) ModelNode(org.jboss.dmr.ModelNode) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)

Aggregations

ConnectionFactoryConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl)23 ConnectionFactoryConfiguration (org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)17 ArrayList (java.util.ArrayList)12 Test (org.junit.Test)10 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)8 ActiveMQConnectionFactory (org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory)5 JMSConfiguration (org.apache.activemq.artemis.jms.server.config.JMSConfiguration)4 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)4 JMSQueueConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl)4 PersistedConnectionFactory (org.apache.activemq.artemis.jms.persistence.config.PersistedConnectionFactory)3 HashMap (java.util.HashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 Connection (javax.jms.Connection)2 ConnectionFactory (javax.jms.ConnectionFactory)2 Queue (javax.jms.Queue)2 NamingException (javax.naming.NamingException)2 Configuration (org.apache.activemq.artemis.core.config.Configuration)2 JndiBindingRegistry (org.apache.activemq.artemis.core.registry.JndiBindingRegistry)2 JMSServerManagerImpl (org.apache.activemq.artemis.jms.server.impl.JMSServerManagerImpl)2 InVMNamingContext (org.apache.activemq.artemis.tests.unit.util.InVMNamingContext)2