Search in sources :

Example 6 with EmbeddedActiveMQ

use of org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ in project dhis2-core by dhis2.

the class ArtemisConfig method createEmbeddedServer.

@Bean
public EmbeddedActiveMQ createEmbeddedServer(ArtemisConfigData artemisConfigData) throws Exception {
    EmbeddedActiveMQ server = new EmbeddedActiveMQ();
    org.apache.activemq.artemis.core.config.Configuration config = new ConfigurationImpl();
    ArtemisEmbeddedConfig embeddedConfig = artemisConfigData.getEmbedded();
    config.addAcceptorConfiguration("in-vm", String.format("vm://0?jms.useAsyncSend=%s&nioRemotingThreads=%d", artemisConfigData.isSendAsync(), embeddedConfig.getNioRemotingThreads()));
    config.setSecurityEnabled(embeddedConfig.isSecurity());
    config.setPersistenceEnabled(embeddedConfig.isPersistence());
    if (locationManager.externalDirectorySet() && embeddedConfig.isPersistence()) {
        String dataDir = locationManager.getExternalDirectoryPath();
        config.setJournalDirectory(dataDir + "/artemis/journal");
        config.setJournalType(JournalType.NIO);
        config.setLargeMessagesDirectory(dataDir + "/artemis/largemessages");
        config.setBindingsDirectory(dataDir + "/artemis/bindings");
        config.setPagingDirectory(dataDir + "/artemis/paging");
    }
    config.addAddressesSetting("#", new AddressSettings().setDeadLetterAddress(SimpleString.toSimpleString("DLQ")).setExpiryAddress(SimpleString.toSimpleString("ExpiryQueue")));
    config.addAddressConfiguration(new CoreAddressConfiguration().setName("DLQ").addRoutingType(RoutingType.ANYCAST).addQueueConfiguration(new CoreQueueConfiguration().setName("DLQ").setRoutingType(RoutingType.ANYCAST)));
    config.addAddressConfiguration(new CoreAddressConfiguration().setName("ExpiryQueue").addRoutingType(RoutingType.ANYCAST).addQueueConfiguration(new CoreQueueConfiguration().setName("ExpiryQueue").setRoutingType(RoutingType.ANYCAST)));
    server.setConfiguration(config);
    return server;
}
Also used : AddressSettings(org.apache.activemq.artemis.core.settings.impl.AddressSettings) CoreAddressConfiguration(org.apache.activemq.artemis.core.config.CoreAddressConfiguration) CoreQueueConfiguration(org.apache.activemq.artemis.core.config.CoreQueueConfiguration) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ConfigurationImpl(org.apache.activemq.artemis.core.config.impl.ConfigurationImpl) EmbeddedActiveMQ(org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ) Bean(org.springframework.context.annotation.Bean)

Aggregations

EmbeddedActiveMQ (org.apache.activemq.artemis.core.server.embedded.EmbeddedActiveMQ)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)2 CoreAddressConfiguration (org.apache.activemq.artemis.core.config.CoreAddressConfiguration)2 ConfigurationImpl (org.apache.activemq.artemis.core.config.impl.ConfigurationImpl)2 AddressSettings (org.apache.activemq.artemis.core.settings.impl.AddressSettings)2 Bean (org.springframework.context.annotation.Bean)2 File (java.io.File)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 QueueConfiguration (org.apache.activemq.artemis.api.core.QueueConfiguration)1 TransportConfiguration (org.apache.activemq.artemis.api.core.TransportConfiguration)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 CoreQueueConfiguration (org.apache.activemq.artemis.core.config.CoreQueueConfiguration)1 AddressFullMessagePolicy (org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy)1 JMSQueueConfiguration (org.apache.activemq.artemis.jms.server.config.JMSQueueConfiguration)1 TopicConfiguration (org.apache.activemq.artemis.jms.server.config.TopicConfiguration)1 ConditionalOnMissingBean (org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean)1