Merge pull request #12680 from graben
* pr/12680: Polish "Prevent warnings when running embedded Artemis" Prevent warnings when running embedded Artemis
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,11 +18,16 @@ package org.springframework.boot.autoconfigure.jms.artemis;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.RoutingType;
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.api.core.TransportConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.CoreQueueConfiguration;
|
||||
import org.apache.activemq.artemis.core.config.impl.ConfigurationImpl;
|
||||
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory;
|
||||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -65,9 +70,22 @@ class ArtemisEmbeddedConfigurationFactory {
|
||||
+ this.properties.getClusterPassword());
|
||||
}
|
||||
configuration.setClusterPassword(this.properties.getClusterPassword());
|
||||
configuration.addAddressConfiguration(createAddressConfiguration("DLQ"));
|
||||
configuration.addAddressConfiguration(createAddressConfiguration("ExpiryQueue"));
|
||||
configuration.addAddressesSetting("#",
|
||||
new AddressSettings()
|
||||
.setDeadLetterAddress(SimpleString.toSimpleString("DLQ"))
|
||||
.setExpiryAddress(SimpleString.toSimpleString("ExpiryQueue")));
|
||||
return configuration;
|
||||
}
|
||||
|
||||
private CoreAddressConfiguration createAddressConfiguration(String name) {
|
||||
return new CoreAddressConfiguration().setName(name)
|
||||
.addRoutingType(RoutingType.ANYCAST)
|
||||
.addQueueConfiguration(new CoreQueueConfiguration().setName(name)
|
||||
.setRoutingType(RoutingType.ANYCAST));
|
||||
}
|
||||
|
||||
private String getDataDir() {
|
||||
if (this.properties.getDataDirectory() != null) {
|
||||
return this.properties.getDataDirectory();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017 the original author or authors.
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,8 +16,14 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.jms.artemis;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.activemq.artemis.api.core.SimpleString;
|
||||
import org.apache.activemq.artemis.core.config.Configuration;
|
||||
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
|
||||
import org.apache.activemq.artemis.core.server.JournalType;
|
||||
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -68,4 +74,26 @@ public class ArtemisEmbeddedConfigurationFactoryTests {
|
||||
assertThat(configuration.getClusterPassword()).isEqualTo("password");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasDlqExpiryQueueAddressSettingsConfigured() {
|
||||
ArtemisProperties properties = new ArtemisProperties();
|
||||
Configuration configuration = new ArtemisEmbeddedConfigurationFactory(properties)
|
||||
.createConfiguration();
|
||||
Map<String, AddressSettings> addressesSettings = configuration
|
||||
.getAddressesSettings();
|
||||
assertThat((Object) addressesSettings.get("#").getDeadLetterAddress())
|
||||
.isEqualTo(SimpleString.toSimpleString("DLQ"));
|
||||
assertThat((Object) addressesSettings.get("#").getExpiryAddress())
|
||||
.isEqualTo(SimpleString.toSimpleString("ExpiryQueue"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hasDlqExpiryQueueConfigured() {
|
||||
ArtemisProperties properties = new ArtemisProperties();
|
||||
Configuration configuration = new ArtemisEmbeddedConfigurationFactory(properties)
|
||||
.createConfiguration();
|
||||
List<CoreAddressConfiguration> addressConfigurations = configuration
|
||||
.getAddressConfigurations();
|
||||
assertThat(addressConfigurations).hasSize(2);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user