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;
}
Aggregations