Search in sources :

Example 36 with ConfigurationImpl

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

the class EmbeddedTestServer method start.

public void start() throws Exception {
    System.out.println("\nStarting EmbeddedTestServer");
    if (activeMQServer == null) {
        Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
        activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
        // set DLA and expiry to avoid spamming the log with warnings
        activeMQServer.getAddressSettingsRepository().addMatch("#", new AddressSettings().setDeadLetterAddress(SimpleString.toSimpleString("DLA")).setExpiryAddress(SimpleString.toSimpleString("Expiry")));
        activeMQServer.start();
    }
    tjws.start();
    manager.setConfiguration(config);
    manager.start();
    tjws.getDeployment().getRegistry().addSingletonResource(manager.getQueueManager().getDestination());
    tjws.getDeployment().getRegistry().addSingletonResource(manager.getTopicManager().getDestination());
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) MessageServiceConfiguration(org.apache.activemq.artemis.rest.MessageServiceConfiguration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Example 37 with ConfigurationImpl

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

the class RawAckTest method setup.

@BeforeClass
public static void setup() throws Exception {
    Configuration configuration = new ConfigurationImpl().setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    activeMQServer = ActiveMQServers.newActiveMQServer(configuration);
    activeMQServer.start();
    HashMap<String, Object> transportConfig = new HashMap<>();
    serverLocator = new ServerLocatorImpl(false, new TransportConfiguration(InVMConnectorFactory.class.getName(), transportConfig));
    sessionFactory = serverLocator.createSessionFactory();
    consumerSessionFactory = serverLocator.createSessionFactory();
    SimpleString addr = SimpleString.toSimpleString("testQueue");
    activeMQServer.addAddressInfo(new AddressInfo(addr, RoutingType.MULTICAST));
    activeMQServer.createQueue(addr, RoutingType.MULTICAST, addr, null, false, false);
    session = sessionFactory.createSession(true, true);
    producer = session.createProducer(addr);
    session.start();
}
Also used : Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) HashMap(java.util.HashMap) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ServerLocatorImpl(org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl) InVMConnectorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMConnectorFactory) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) BeforeClass(org.junit.BeforeClass)

Example 38 with ConfigurationImpl

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

the class ClusteredMessageCounterTest method createBasicConfig.

@Override
protected ConfigurationImpl createBasicConfig(final int serverID) {
    ConfigurationImpl config = super.createBasicConfig(serverID);
    Map<String, AddressSettings> addrSettingsMap = config.getAddressesSettings();
    AddressSettings addrSettings = new AddressSettings();
    addrSettings.setMaxSizeBytes(10 * 1024);
    addrSettings.setPageSizeBytes(5 * 1024);
    addrSettings.setAddressFullMessagePolicy(AddressFullMessagePolicy.PAGE);
    addrSettingsMap.put("queues", addrSettings);
    if (serverID == 1) {
        config.setMessageCounterEnabled(true);
    }
    return config;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)

Example 39 with ConfigurationImpl

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

the class EmbeddedServerTest method setup.

@Before
public void setup() {
    configuration = new ConfigurationImpl().setJournalDirectory(SERVER_JOURNAL_DIR).setPersistenceEnabled(false).setSecurityEnabled(false).addAcceptorConfiguration(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
    server = ActiveMQServers.newActiveMQServer(configuration);
    try {
        server.start();
    } catch (Exception e) {
        Assert.fail();
    }
}
Also used : TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) InVMAcceptorFactory(org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory) Before(org.junit.Before)

Example 40 with ConfigurationImpl

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

the class ActiveMQContextListener method contextInitialized.

public void contextInitialized(Injector injector) {
    org.candlepin.common.config.Configuration candlepinConfig = injector.getInstance(org.candlepin.common.config.Configuration.class);
    if (activeMQServer == null) {
        Configuration config = new ConfigurationImpl();
        HashSet<TransportConfiguration> transports = new HashSet<>();
        transports.add(new TransportConfiguration(InVMAcceptorFactory.class.getName()));
        config.setAcceptorConfigurations(transports);
        // alter the default pass to silence log output
        config.setClusterUser(null);
        config.setClusterPassword(null);
        // in vm, who needs security?
        config.setSecurityEnabled(false);
        config.setJournalType(JournalType.NIO);
        config.setCreateBindingsDir(true);
        config.setCreateJournalDir(true);
        String baseDir = candlepinConfig.getString(ConfigProperties.ACTIVEMQ_BASE_DIR);
        config.setBindingsDirectory(new File(baseDir, "bindings").toString());
        config.setJournalDirectory(new File(baseDir, "journal").toString());
        config.setLargeMessagesDirectory(new File(baseDir, "largemsgs").toString());
        config.setPagingDirectory(new File(baseDir, "paging").toString());
        Map<String, AddressSettings> settings = new HashMap<>();
        AddressSettings pagingConfig = new AddressSettings();
        String addressPolicyString = candlepinConfig.getString(ConfigProperties.ACTIVEMQ_ADDRESS_FULL_POLICY);
        long maxQueueSizeInMb = candlepinConfig.getInt(ConfigProperties.ACTIVEMQ_MAX_QUEUE_SIZE);
        long maxPageSizeInMb = candlepinConfig.getInt(ConfigProperties.ACTIVEMQ_MAX_PAGE_SIZE);
        AddressFullMessagePolicy addressPolicy = null;
        if (addressPolicyString.equals("PAGE")) {
            addressPolicy = AddressFullMessagePolicy.PAGE;
        } else if (addressPolicyString.equals("BLOCK")) {
            addressPolicy = AddressFullMessagePolicy.BLOCK;
        } else {
            throw new IllegalArgumentException("Unknown ACTIVEMQ_ADDRESS_FULL_POLICY: " + addressPolicyString + " . Please use one of: PAGE, BLOCK");
        }
        // Paging sizes need to be converted to bytes
        pagingConfig.setMaxSizeBytes(maxQueueSizeInMb * FileUtils.ONE_MB);
        if (addressPolicy == AddressFullMessagePolicy.PAGE) {
            pagingConfig.setPageSizeBytes(maxPageSizeInMb * FileUtils.ONE_MB);
        }
        pagingConfig.setAddressFullMessagePolicy(addressPolicy);
        // Enable for all the queues
        settings.put("#", pagingConfig);
        config.setAddressesSettings(settings);
        int maxScheduledThreads = candlepinConfig.getInt(ConfigProperties.ACTIVEMQ_MAX_SCHEDULED_THREADS);
        int maxThreads = candlepinConfig.getInt(ConfigProperties.ACTIVEMQ_MAX_THREADS);
        if (maxThreads != -1) {
            config.setThreadPoolMaxSize(maxThreads);
        }
        if (maxScheduledThreads != -1) {
            config.setScheduledThreadPoolMaxSize(maxScheduledThreads);
        }
        /**
         * Anything up to size of LARGE_MSG_SIZE may be needed to be written to the Journal,
         * so we must set buffer size accordingly.
         *
         * If buffer size would be < LARGE_MSG_SIZE we may get exceptions such as this:
         * Can't write records bigger than the bufferSize(XXXYYY) on the journal
         */
        int largeMsgSize = candlepinConfig.getInt(ConfigProperties.ACTIVEMQ_LARGE_MSG_SIZE);
        config.setJournalBufferSize_AIO(largeMsgSize);
        config.setJournalBufferSize_NIO(largeMsgSize);
        activeMQServer = new EmbeddedActiveMQ();
        activeMQServer.setConfiguration(config);
    }
    try {
        activeMQServer.start();
        log.info("ActiveMQ server started");
    } catch (Exception e) {
        log.error("Failed to start ActiveMQ message server:", e);
        throw new RuntimeException(e);
    }
    setupAmqp(injector, candlepinConfig);
    cleanupOldQueues();
    List<String> listeners = getActiveMQListeners(candlepinConfig);
    eventSource = injector.getInstance(EventSource.class);
    for (int i = 0; i < listeners.size(); i++) {
        try {
            Class<?> clazz = this.getClass().getClassLoader().loadClass(listeners.get(i));
            eventSource.registerListener((EventListener) injector.getInstance(clazz));
        } catch (Exception e) {
            log.warn("Unable to register listener " + listeners.get(i), e);
        }
    }
    // Initialize the Event sink AFTER the internal server has been
    // created and started.
    EventSink sink = injector.getInstance(EventSink.class);
    try {
        sink.initialize();
    } catch (Exception e) {
        log.error("Failed to initialize EventSink:", e);
        throw new RuntimeException(e);
    }
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) Configuration(org.apache.activemq.artemis.core.config.Configuration) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) AddressFullMessagePolicy(org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy) HashMap(java.util.HashMap) TransportConfiguration(org.apache.activemq.artemis.api.core.TransportConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) File(java.io.File) HashSet(java.util.HashSet) EmbeddedActiveMQ(org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ)

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