Search in sources :

Example 21 with ConfigurationImpl

use of org.apache.activemq.artemis.core.config.impl.ConfigurationImpl in project wildfly by wildfly.

the class ServerAdd method transformConfig.

/**
     * Transform the detyped operation parameters into the ActiveMQ configuration.
     *
     * @param context the operation context
     * @param serverName the name of the ActiveMQ instance
     * @param model the subsystem root resource model
     * @return the ActiveMQ configuration
     */
private Configuration transformConfig(final OperationContext context, String serverName, final ModelNode model) throws OperationFailedException {
    Configuration configuration = new ConfigurationImpl();
    configuration.setName(serverName);
    configuration.setEnabledAsyncConnectionExecution(ASYNC_CONNECTION_EXECUTION_ENABLED.resolveModelAttribute(context, model).asBoolean());
    configuration.setClusterPassword(CLUSTER_PASSWORD.resolveModelAttribute(context, model).asString());
    configuration.setClusterUser(CLUSTER_USER.resolveModelAttribute(context, model).asString());
    configuration.setConnectionTTLOverride(CONNECTION_TTL_OVERRIDE.resolveModelAttribute(context, model).asInt());
    configuration.setCreateBindingsDir(CREATE_BINDINGS_DIR.resolveModelAttribute(context, model).asBoolean());
    configuration.setCreateJournalDir(CREATE_JOURNAL_DIR.resolveModelAttribute(context, model).asBoolean());
    configuration.setIDCacheSize(ID_CACHE_SIZE.resolveModelAttribute(context, model).asInt());
    // TODO do we want to allow the jmx configuration ?
    configuration.setJMXDomain(JMX_DOMAIN.resolveModelAttribute(context, model).asString());
    configuration.setJMXManagementEnabled(JMX_MANAGEMENT_ENABLED.resolveModelAttribute(context, model).asBoolean());
    // Journal
    final JournalType journalType = JournalType.valueOf(JOURNAL_TYPE.resolveModelAttribute(context, model).asString());
    configuration.setJournalType(journalType);
    // AIO Journal
    configuration.setJournalBufferSize_AIO(JOURNAL_BUFFER_SIZE.resolveModelAttribute(context, model).asInt(ActiveMQDefaultConfiguration.getDefaultJournalBufferSizeAio()));
    configuration.setJournalBufferTimeout_AIO(JOURNAL_BUFFER_TIMEOUT.resolveModelAttribute(context, model).asInt(ActiveMQDefaultConfiguration.getDefaultJournalBufferTimeoutAio()));
    configuration.setJournalMaxIO_AIO(JOURNAL_MAX_IO.resolveModelAttribute(context, model).asInt(ActiveMQDefaultConfiguration.getDefaultJournalMaxIoAio()));
    // NIO Journal
    configuration.setJournalBufferSize_NIO(JOURNAL_BUFFER_SIZE.resolveModelAttribute(context, model).asInt(ActiveMQDefaultConfiguration.getDefaultJournalBufferSizeNio()));
    configuration.setJournalBufferTimeout_NIO(JOURNAL_BUFFER_TIMEOUT.resolveModelAttribute(context, model).asInt(ActiveMQDefaultConfiguration.getDefaultJournalBufferTimeoutNio()));
    configuration.setJournalMaxIO_NIO(JOURNAL_MAX_IO.resolveModelAttribute(context, model).asInt(ActiveMQDefaultConfiguration.getDefaultJournalMaxIoNio()));
    //
    configuration.setJournalCompactMinFiles(JOURNAL_COMPACT_MIN_FILES.resolveModelAttribute(context, model).asInt());
    configuration.setJournalCompactPercentage(JOURNAL_COMPACT_PERCENTAGE.resolveModelAttribute(context, model).asInt());
    configuration.setJournalFileSize(JOURNAL_FILE_SIZE.resolveModelAttribute(context, model).asInt());
    configuration.setJournalMinFiles(JOURNAL_MIN_FILES.resolveModelAttribute(context, model).asInt());
    configuration.setJournalPoolFiles(JOURNAL_POOL_FILES.resolveModelAttribute(context, model).asInt());
    configuration.setJournalSyncNonTransactional(JOURNAL_SYNC_NON_TRANSACTIONAL.resolveModelAttribute(context, model).asBoolean());
    configuration.setJournalSyncTransactional(JOURNAL_SYNC_TRANSACTIONAL.resolveModelAttribute(context, model).asBoolean());
    configuration.setLogJournalWriteRate(LOG_JOURNAL_WRITE_RATE.resolveModelAttribute(context, model).asBoolean());
    configuration.setManagementAddress(SimpleString.toSimpleString(MANAGEMENT_ADDRESS.resolveModelAttribute(context, model).asString()));
    configuration.setManagementNotificationAddress(SimpleString.toSimpleString(MANAGEMENT_NOTIFICATION_ADDRESS.resolveModelAttribute(context, model).asString()));
    configuration.setMemoryMeasureInterval(MEMORY_MEASURE_INTERVAL.resolveModelAttribute(context, model).asLong());
    configuration.setMemoryWarningThreshold(MEMORY_WARNING_THRESHOLD.resolveModelAttribute(context, model).asInt());
    configuration.setMessageCounterEnabled(STATISTICS_ENABLED.resolveModelAttribute(context, model).asBoolean());
    configuration.setMessageCounterSamplePeriod(MESSAGE_COUNTER_SAMPLE_PERIOD.resolveModelAttribute(context, model).asInt());
    configuration.setMessageCounterMaxDayHistory(MESSAGE_COUNTER_MAX_DAY_HISTORY.resolveModelAttribute(context, model).asInt());
    configuration.setMessageExpiryScanPeriod(MESSAGE_EXPIRY_SCAN_PERIOD.resolveModelAttribute(context, model).asLong());
    configuration.setMessageExpiryThreadPriority(MESSAGE_EXPIRY_THREAD_PRIORITY.resolveModelAttribute(context, model).asInt());
    configuration.setJournalPerfBlastPages(PERF_BLAST_PAGES.resolveModelAttribute(context, model).asInt());
    configuration.setPersistDeliveryCountBeforeDelivery(PERSIST_DELIVERY_COUNT_BEFORE_DELIVERY.resolveModelAttribute(context, model).asBoolean());
    configuration.setPageMaxConcurrentIO(PAGE_MAX_CONCURRENT_IO.resolveModelAttribute(context, model).asInt());
    configuration.setPersistenceEnabled(PERSISTENCE_ENABLED.resolveModelAttribute(context, model).asBoolean());
    configuration.setPersistIDCache(PERSIST_ID_CACHE.resolveModelAttribute(context, model).asBoolean());
    configuration.setRunSyncSpeedTest(RUN_SYNC_SPEED_TEST.resolveModelAttribute(context, model).asBoolean());
    configuration.setScheduledThreadPoolMaxSize(SCHEDULED_THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
    configuration.setSecurityEnabled(SECURITY_ENABLED.resolveModelAttribute(context, model).asBoolean());
    configuration.setSecurityInvalidationInterval(SECURITY_INVALIDATION_INTERVAL.resolveModelAttribute(context, model).asLong());
    configuration.setServerDumpInterval(SERVER_DUMP_INTERVAL.resolveModelAttribute(context, model).asLong());
    configuration.setThreadPoolMaxSize(THREAD_POOL_MAX_SIZE.resolveModelAttribute(context, model).asInt());
    configuration.setTransactionTimeout(TRANSACTION_TIMEOUT.resolveModelAttribute(context, model).asLong());
    configuration.setTransactionTimeoutScanPeriod(TRANSACTION_TIMEOUT_SCAN_PERIOD.resolveModelAttribute(context, model).asLong());
    configuration.setWildcardRoutingEnabled(WILD_CARD_ROUTING_ENABLED.resolveModelAttribute(context, model).asBoolean());
    processStorageConfiguration(context, model, configuration);
    addHAPolicyConfiguration(context, configuration, model);
    processAddressSettings(context, configuration, model);
    processSecuritySettings(context, configuration, model);
    // Add in items from child resources
    GroupingHandlerAdd.addGroupingHandlerConfig(context, configuration, model);
    DiscoveryGroupAdd.addDiscoveryGroupConfigs(context, configuration, model);
    DivertAdd.addDivertConfigs(context, configuration, model);
    QueueAdd.addQueueConfigs(context, configuration, model);
    BridgeAdd.addBridgeConfigs(context, configuration, model);
    ClusterConnectionAdd.addClusterConnectionConfigs(context, configuration, model);
    ConnectorServiceDefinition.addConnectorServiceConfigs(context, configuration, model);
    return configuration;
}
Also used : HAPolicyConfigurationBuilder.addHAPolicyConfiguration(org.wildfly.extension.messaging.activemq.ha.HAPolicyConfigurationBuilder.addHAPolicyConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) JournalType(org.apache.activemq.artemis.core.server.JournalType) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Example 22 with ConfigurationImpl

use of org.apache.activemq.artemis.core.config.impl.ConfigurationImpl in project camel by apache.

the class Jms2TestSupport method configureBroker.

protected void configureBroker(EmbeddedJMS broker) throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setJournalDirectory("target/data/journal").setSecurityEnabled(false).addAcceptorConfiguration("connector", brokerUri + "?protocols=CORE,AMQP,HORNETQ,OPENWIRE").addAcceptorConfiguration("vm", "vm://broker").addConnectorConfiguration("connector", new TransportConfiguration(NettyConnectorFactory.class.getName()));
    JMSConfiguration jmsConfig = new JMSConfigurationImpl();
    ConnectionFactoryConfiguration cfConfig = new ConnectionFactoryConfigurationImpl().setName("cf").setConnectorNames(Arrays.asList("connector")).setBindings("cf");
    jmsConfig.getConnectionFactoryConfigurations().add(cfConfig);
    JMSQueueConfiguration queueConfig = new JMSQueueConfigurationImpl().setName("queue1").setDurable(false).setBindings("queue/queue1");
    jmsConfig.getQueueConfigurations().add(queueConfig);
    broker.setConfiguration(configuration).setJmsConfiguration(jmsConfig);
}
Also used : JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration) JMSQueueConfiguration(org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration) JMSConfiguration(org.apache.activemq.artemis.jms.server.config.JMSConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) 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) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) JMSConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) ConnectionFactoryConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.ConnectionFactoryConfigurationImpl) JMSQueueConfigurationImpl(org.apache.activemq.artemis.jms.server.config.impl.JMSQueueConfigurationImpl) ConnectionFactoryConfiguration(org.apache.activemq.artemis.jms.server.config.ConnectionFactoryConfiguration)

Example 23 with ConfigurationImpl

use of org.apache.activemq.artemis.core.config.impl.ConfigurationImpl in project activemq-artemis by apache.

the class ArtemisBrokerBase method createDefaultConfig.

protected Configuration createDefaultConfig(final Map<String, Object> params, final String... acceptors) throws Exception {
    ConfigurationImpl configuration = createBasicConfig(-1).setJMXManagementEnabled(false).clearAcceptorConfigurations();
    for (String acceptor : acceptors) {
        TransportConfiguration transportConfig = new TransportConfiguration(acceptor, params);
        configuration.addAcceptorConfiguration(transportConfig);
    }
    return configuration;
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Example 24 with ConfigurationImpl

use of org.apache.activemq.artemis.core.config.impl.ConfigurationImpl in project activemq-artemis by apache.

the class JMSSaslExternalTest method startServer.

@Before
public void startServer() throws Exception {
    ConfigurationImpl configuration = createBasicConfig(0).setJMXManagementEnabled(false);
    ActiveMQJAASSecurityManager securityManager = new ActiveMQJAASSecurityManager("CertLogin");
    server = addServer(ActiveMQServers.newActiveMQServer(configuration.setSecurityEnabled(true), ManagementFactory.getPlatformMBeanServer(), securityManager, false));
    Map<String, Object> params = new HashMap<>();
    params.put(TransportConstants.SSL_ENABLED_PROP_NAME, true);
    params.put(TransportConstants.KEYSTORE_PATH_PROP_NAME, "keystore1.jks");
    params.put(TransportConstants.KEYSTORE_PASSWORD_PROP_NAME, "changeit");
    params.put(TransportConstants.TRUSTSTORE_PATH_PROP_NAME, "truststore.jks");
    params.put(TransportConstants.TRUSTSTORE_PASSWORD_PROP_NAME, "changeit");
    params.put(TransportConstants.NEED_CLIENT_AUTH_PROP_NAME, true);
    Map<String, Object> extraParams = new HashMap<>();
    extraParams.put("saslMechanisms", "EXTERNAL");
    server.getConfiguration().addAcceptorConfiguration(new TransportConfiguration(NettyAcceptorFactory.class.getCanonicalName(), params, "netty", extraParams));
    // role mapping via CertLogin - TextFileCertificateLoginModule
    final String roleName = "widgets";
    Role role = new Role(roleName, true, true, true, true, true, true, true, true, true, true);
    Set<Role> roles = new HashSet<>();
    roles.add(role);
    server.getSecurityRepository().addMatch("TEST", roles);
    server.start();
}
Also used : Role(org.apache.activemq.artemis.core.security.Role) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ActiveMQJAASSecurityManager(org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 25 with ConfigurationImpl

use of org.apache.activemq.artemis.core.config.impl.ConfigurationImpl in project activemq-artemis by apache.

the class FileConfigurationParser method parseMainConfig.

public Configuration parseMainConfig(final InputStream input) throws Exception {
    Reader reader = new InputStreamReader(input);
    String xml = XMLUtil.readerToString(reader);
    xml = XMLUtil.replaceSystemProps(xml);
    Element e = XMLUtil.stringToElement(xml);
    SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
    Schema schema = schemaFactory.newSchema(XMLUtil.findResource("schema/artemis-server.xsd"));
    Validator validator = schema.newValidator();
    try {
        validator.validate(new DOMSource(e));
    } catch (Exception ex) {
        ActiveMQServerLogger.LOGGER.error(ex.getMessage());
    }
    Configuration config = new ConfigurationImpl();
    parseMainConfig(e, config);
    return config;
}
Also used : SchemaFactory(javax.xml.validation.SchemaFactory) DOMSource(javax.xml.transform.dom.DOMSource) InputStreamReader(java.io.InputStreamReader) TransformerConfiguration(org.apache.activemq.artemis.core.config.TransformerConfiguration) DivertConfiguration(org.apache.activemq.artemis.core.config.DivertConfiguration) GroupingHandlerConfiguration(org.apache.activemq.artemis.core.server.group.impl.GroupingHandlerConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) Configuration(org.apache.activemq.artemis.core.config.Configuration) SharedStoreMasterPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration) FileStorageConfiguration(org.apache.activemq.artemis.core.config.storage.FileStorageConfiguration) ActiveMQDefaultConfiguration(org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration) DatabaseStorageConfiguration(org.apache.activemq.artemis.core.config.storage.DatabaseStorageConfiguration) WildcardConfiguration(org.apache.activemq.artemis.core.config.WildcardConfiguration) ClusterConnectionConfiguration(org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration) LiveOnlyPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration) ReplicatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicatedPolicyConfiguration) ReplicaPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ReplicaPolicyConfiguration) SharedStoreSlavePolicyConfiguration(org.apache.activemq.artemis.core.config.ha.SharedStoreSlavePolicyConfiguration) BridgeConfiguration(org.apache.activemq.artemis.core.config.BridgeConfiguration) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) DiscoveryGroupConfiguration(org.apache.activemq.artemis.api.core.DiscoveryGroupConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) ConnectorServiceConfiguration(org.apache.activemq.artemis.core.config.ConnectorServiceConfiguration) BroadcastGroupConfiguration(org.apache.activemq.artemis.api.core.BroadcastGroupConfiguration) ColocatedPolicyConfiguration(org.apache.activemq.artemis.core.config.ha.ColocatedPolicyConfiguration) ScaleDownConfiguration(org.apache.activemq.artemis.core.config.ScaleDownConfiguration) Element(org.w3c.dom.Element) Schema(javax.xml.validation.Schema) Reader(java.io.Reader) InputStreamReader(java.io.InputStreamReader) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) Validator(javax.xml.validation.Validator)

Aggregations

ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)45 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)26 Configuration (org.apache.activemq.artemis.core.config.Configuration)21 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)13 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)12 Before (org.junit.Before)12 HashMap (java.util.HashMap)11 ActiveMQJAASSecurityManager (org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager)7 File (java.io.File)5 JMSConfigurationImpl (org.apache.activemq.artemis.jms.server.config.impl.JMSConfigurationImpl)5 HashSet (java.util.HashSet)4 InVMConnectorFactory (org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory)4 ClusterConnectionConfiguration (org.apache.activemq.artemis.core.config.ClusterConnectionConfiguration)3 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)3 JournalStorageManager (org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager)3 Role (org.apache.activemq.artemis.core.security.Role)3 OrderedExecutorFactory (org.apache.activemq.artemis.utils.actors.OrderedExecutorFactory)3 Test (org.junit.Test)3 Set (java.util.Set)2 ActiveMQDefaultConfiguration (org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration)2