ARTEMIS-4157: Fix error setting broker properties for AddressSettings

This commit is contained in:
Rakhi Kumari 2023-02-07 18:19:23 +05:30 committed by Gary Tully
parent 69e21a0eb7
commit 17c760ab7b
4 changed files with 134 additions and 14 deletions

View File

@ -409,7 +409,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isAutoCreateQueues() {
public Boolean isAutoCreateQueues() {
return autoCreateQueues != null ? autoCreateQueues : AddressSettings.DEFAULT_AUTO_CREATE_QUEUES;
}
@ -418,7 +418,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isAutoDeleteQueues() {
public Boolean isAutoDeleteQueues() {
return autoDeleteQueues != null ? autoDeleteQueues : AddressSettings.DEFAULT_AUTO_DELETE_QUEUES;
}
@ -432,7 +432,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isAutoDeleteCreatedQueues() {
public Boolean isAutoDeleteCreatedQueues() {
return autoDeleteCreatedQueues != null ? autoDeleteCreatedQueues : AddressSettings.DEFAULT_AUTO_DELETE_CREATED_QUEUES;
}
@ -464,7 +464,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isAutoCreateAddresses() {
public Boolean isAutoCreateAddresses() {
return autoCreateAddresses != null ? autoCreateAddresses : AddressSettings.DEFAULT_AUTO_CREATE_ADDRESSES;
}
@ -473,7 +473,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isAutoDeleteAddresses() {
public Boolean isAutoDeleteAddresses() {
return autoDeleteAddresses != null ? autoDeleteAddresses : AddressSettings.DEFAULT_AUTO_DELETE_ADDRESSES;
}
@ -509,7 +509,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return configDeleteDiverts != null ? configDeleteDiverts : AddressSettings.DEFAULT_CONFIG_DELETE_DIVERTS;
}
public int getDefaultMaxConsumers() {
public Integer getDefaultMaxConsumers() {
return defaultMaxConsumers != null ? defaultMaxConsumers : ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers();
}
@ -518,7 +518,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public int getDefaultConsumersBeforeDispatch() {
public Integer getDefaultConsumersBeforeDispatch() {
return defaultConsumersBeforeDispatch != null ? defaultConsumersBeforeDispatch : ActiveMQDefaultConfiguration.getDefaultConsumersBeforeDispatch();
}
@ -527,7 +527,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public long getDefaultDelayBeforeDispatch() {
public Long getDefaultDelayBeforeDispatch() {
return defaultDelayBeforeDispatch != null ? defaultDelayBeforeDispatch : ActiveMQDefaultConfiguration.getDefaultDelayBeforeDispatch();
}
@ -536,7 +536,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isDefaultPurgeOnNoConsumers() {
public Boolean isDefaultPurgeOnNoConsumers() {
return defaultPurgeOnNoConsumers != null ? defaultPurgeOnNoConsumers : ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers();
}
@ -590,7 +590,7 @@ public class AddressSettings implements Mergeable<AddressSettings>, Serializable
return this;
}
public boolean isDefaultExclusiveQueue() {
public Boolean isDefaultExclusiveQueue() {
return defaultExclusiveQueue != null ? defaultExclusiveQueue : ActiveMQDefaultConfiguration.getDefaultExclusive();
}

View File

@ -38,6 +38,7 @@ import java.util.stream.Collectors;
import org.apache.activemq.artemis.ArtemisConstants;
import org.apache.activemq.artemis.api.config.ActiveMQDefaultConfiguration;
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;
@ -64,8 +65,11 @@ import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancing
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin;
import org.apache.activemq.artemis.core.server.routing.KeyType;
import org.apache.activemq.artemis.core.server.routing.policies.ConsistentHashModuloPolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.DeletionPolicy;
import org.apache.activemq.artemis.core.settings.impl.ResourceLimitSettings;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.core.settings.impl.SlowConsumerThresholdMeasurementUnit;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.apache.activemq.artemis.utils.critical.CriticalAnalyzerPolicy;
@ -1005,13 +1009,129 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
properties.put("addressesSettings.#.expiryAddress", "sharedExpiry"); // verify @Deprecation double plural still works
properties.put("addressSettings.NeedToTrackExpired.expiryAddress", "important");
properties.put("addressSettings.\"Name.With.Dots\".expiryAddress", "moreImportant");
properties.put("addressSettings.NeedToSet.autoCreateExpiryResources", "true");
properties.put("addressSettings.NeedToSet.deadLetterAddress", "iamDeadLetterAdd");
properties.put("addressSettings.NeedToSet.expiryQueuePrefix", "add1Expiry");
properties.put("addressSettings.NeedToSet.maxReadPageBytes", 20000000);
properties.put("addressSettings.NeedToSet.deadLetterQueuePrefix", "iamDeadLetterQueuePre");
properties.put("addressSettings.NeedToSet.managementMessageAttributeSizeLimit", 512);
properties.put("addressSettings.NeedToSet.pageSizeBytes", 12345);
properties.put("addressSettings.NeedToSet.expiryQueueSuffix", "add1ExpirySuffix");
properties.put("addressSettings.NeedToSet.expiryDelay", 44);
properties.put("addressSettings.NeedToSet.minExpiryDelay", 5);
properties.put("addressSettings.NeedToSet.maxExpiryDelay", 10);
properties.put("addressSettings.NeedToSet.enableIngressTimestamp", "true");
properties.put("addressSettings.NeedToSet.managementBrowsePageSize", 300);
properties.put("addressSettings.NeedToSet.retroactiveMessageCount", -1);
properties.put("addressSettings.NeedToSet.maxDeliveryAttempts", 10);
properties.put("addressSettings.NeedToSet.defaultGroupFirstKey", "add1Key");
properties.put("addressSettings.NeedToSet.slowConsumerCheckPeriod", 100);
properties.put("addressSettings.NeedToSet.defaultLastValueKey", "add1Lvk");
properties.put("addressSettings.NeedToSet.configDeleteDiverts", DeletionPolicy.FORCE);
properties.put("addressSettings.NeedToSet.defaultConsumerWindowSize", 1000);
properties.put("addressSettings.NeedToSet.messageCounterHistoryDayLimit", 7);
properties.put("addressSettings.NeedToSet.defaultGroupRebalance", "true");
properties.put("addressSettings.NeedToSet.defaultQueueRoutingType", RoutingType.ANYCAST);
properties.put("addressSettings.NeedToSet.autoDeleteQueuesMessageCount", 6789);
properties.put("addressSettings.NeedToSet.addressFullMessagePolicy", AddressFullMessagePolicy.DROP);
properties.put("addressSettings.NeedToSet.maxSizeBytes", 6666);
properties.put("addressSettings.NeedToSet.redistributionDelay", 22);
properties.put("addressSettings.NeedToSet.maxSizeBytesRejectThreshold", 12334);
properties.put("addressSettings.NeedToSet.defaultAddressRoutingType", RoutingType.ANYCAST);
properties.put("addressSettings.NeedToSet.autoCreateDeadLetterResources", "true");
properties.put("addressSettings.NeedToSet.pageCacheMaxSize", 10);
properties.put("addressSettings.NeedToSet.maxRedeliveryDelay", 66);
properties.put("addressSettings.NeedToSet.maxSizeMessages", 10000000);
properties.put("addressSettings.NeedToSet.redeliveryMultiplier", 2.1);
properties.put("addressSettings.NeedToSet.defaultRingSize", -2);
properties.put("addressSettings.NeedToSet.defaultLastValueQueue", "true");
properties.put("addressSettings.NeedToSet.redeliveryCollisionAvoidanceFactor", 5.0);
properties.put("addressSettings.NeedToSet.autoDeleteQueuesDelay", 3);
properties.put("addressSettings.NeedToSet.autoDeleteAddressesDelay", 33);
properties.put("addressSettings.NeedToSet.enableMetrics", "false");
properties.put("addressSettings.NeedToSet.sendToDLAOnNoRoute", "true");
properties.put("addressSettings.NeedToSet.slowConsumerThresholdMeasurementUnit", SlowConsumerThresholdMeasurementUnit.MESSAGES_PER_HOUR);
properties.put("addressSettings.NeedToSet.deadLetterQueueSuffix", "iamDeadLetterQueueSuf");
properties.put("addressSettings.NeedToSet.queuePrefetch", 900);
properties.put("addressSettings.NeedToSet.defaultNonDestructive", "true");
properties.put("addressSettings.NeedToSet.configDeleteAddresses", DeletionPolicy.FORCE);
properties.put("addressSettings.NeedToSet.slowConsumerThreshold", 10);
properties.put("addressSettings.NeedToSet.configDeleteQueues", DeletionPolicy.FORCE);
properties.put("addressSettings.NeedToSet.autoCreateAddresses", "false");
properties.put("addressSettings.NeedToSet.autoDeleteQueues", "false");
properties.put("addressSettings.NeedToSet.defaultConsumersBeforeDispatch", 1);
properties.put("addressSettings.NeedToSet.defaultPurgeOnNoConsumers", "true");
properties.put("addressSettings.NeedToSet.autoCreateQueues", "false");
properties.put("addressSettings.NeedToSet.autoDeleteAddresses", "false");
properties.put("addressSettings.NeedToSet.defaultDelayBeforeDispatch", 77);
properties.put("addressSettings.NeedToSet.autoDeleteCreatedQueues", "true");
properties.put("addressSettings.NeedToSet.defaultExclusiveQueue", "true");
properties.put("addressSettings.NeedToSet.defaultMaxConsumers", 10);
configuration.parsePrefixedProperties(properties, null);
Assert.assertEquals(3, configuration.getAddressSettings().size());
Assert.assertEquals(4, configuration.getAddressSettings().size());
Assert.assertEquals(SimpleString.toSimpleString("sharedExpiry"), configuration.getAddressSettings().get("#").getExpiryAddress());
Assert.assertEquals(SimpleString.toSimpleString("important"), configuration.getAddressSettings().get("NeedToTrackExpired").getExpiryAddress());
Assert.assertEquals(SimpleString.toSimpleString("moreImportant"), configuration.getAddressSettings().get("Name.With.Dots").getExpiryAddress());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isAutoCreateExpiryResources());
Assert.assertEquals(SimpleString.toSimpleString("iamDeadLetterAdd"), configuration.getAddressSettings().get("NeedToSet").getDeadLetterAddress());
Assert.assertEquals(SimpleString.toSimpleString("add1Expiry"), configuration.getAddressSettings().get("NeedToSet").getExpiryQueuePrefix());
Assert.assertEquals(20000000, configuration.getAddressSettings().get("NeedToSet").getMaxReadPageBytes());
Assert.assertEquals(512, configuration.getAddressSettings().get("NeedToSet").getManagementMessageAttributeSizeLimit());
Assert.assertEquals(SimpleString.toSimpleString("iamDeadLetterQueuePre"), configuration.getAddressSettings().get("NeedToSet").getDeadLetterQueuePrefix());
Assert.assertEquals(12345, configuration.getAddressSettings().get("NeedToSet").getPageSizeBytes());
Assert.assertEquals(SimpleString.toSimpleString("add1ExpirySuffix"), configuration.getAddressSettings().get("NeedToSet").getExpiryQueueSuffix());
Assert.assertEquals(Long.valueOf(44), configuration.getAddressSettings().get("NeedToSet").getExpiryDelay());
Assert.assertEquals(Long.valueOf(5), configuration.getAddressSettings().get("NeedToSet").getMinExpiryDelay());
Assert.assertEquals(Long.valueOf(10), configuration.getAddressSettings().get("NeedToSet").getMaxExpiryDelay());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isEnableIngressTimestamp());
Assert.assertEquals(300, configuration.getAddressSettings().get("NeedToSet").getManagementBrowsePageSize());
Assert.assertEquals(-1, configuration.getAddressSettings().get("NeedToSet").getRetroactiveMessageCount());
Assert.assertEquals(10, configuration.getAddressSettings().get("NeedToSet").getMaxDeliveryAttempts());
Assert.assertEquals(SimpleString.toSimpleString("add1Key"), configuration.getAddressSettings().get("NeedToSet").getDefaultGroupFirstKey());
Assert.assertEquals(100, configuration.getAddressSettings().get("NeedToSet").getSlowConsumerCheckPeriod());
Assert.assertEquals(SimpleString.toSimpleString("add1Lvk"), configuration.getAddressSettings().get("NeedToSet").getDefaultLastValueKey());
Assert.assertEquals(DeletionPolicy.FORCE, configuration.getAddressSettings().get("NeedToSet").getConfigDeleteDiverts());
Assert.assertEquals(1000, configuration.getAddressSettings().get("NeedToSet").getDefaultConsumerWindowSize());
Assert.assertEquals(7, configuration.getAddressSettings().get("NeedToSet").getMessageCounterHistoryDayLimit());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isDefaultGroupRebalance());
Assert.assertEquals(RoutingType.ANYCAST, configuration.getAddressSettings().get("NeedToSet").getDefaultQueueRoutingType());
Assert.assertEquals(6789, configuration.getAddressSettings().get("NeedToSet").getAutoDeleteQueuesMessageCount());
Assert.assertEquals(AddressFullMessagePolicy.DROP, configuration.getAddressSettings().get("NeedToSet").getAddressFullMessagePolicy());
Assert.assertEquals(6666, configuration.getAddressSettings().get("NeedToSet").getMaxSizeBytes());
Assert.assertEquals(22, configuration.getAddressSettings().get("NeedToSet").getRedistributionDelay());
Assert.assertEquals(12334, configuration.getAddressSettings().get("NeedToSet").getMaxSizeBytesRejectThreshold());
Assert.assertEquals(RoutingType.ANYCAST, configuration.getAddressSettings().get("NeedToSet").getDefaultAddressRoutingType());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isAutoCreateDeadLetterResources());
Assert.assertEquals(10, configuration.getAddressSettings().get("NeedToSet").getPageCacheMaxSize());
Assert.assertEquals(66, configuration.getAddressSettings().get("NeedToSet").getMaxRedeliveryDelay());
Assert.assertEquals(10000000, configuration.getAddressSettings().get("NeedToSet").getMaxSizeMessages());
Assert.assertEquals(2.1, configuration.getAddressSettings().get("NeedToSet").getRedeliveryMultiplier(), .01);
Assert.assertEquals(-2, configuration.getAddressSettings().get("NeedToSet").getDefaultRingSize());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isDefaultLastValueQueue());
Assert.assertEquals(5.0, configuration.getAddressSettings().get("NeedToSet").getRedeliveryCollisionAvoidanceFactor(), .01);
Assert.assertEquals(3, configuration.getAddressSettings().get("NeedToSet").getAutoDeleteQueuesDelay());
Assert.assertEquals(33, configuration.getAddressSettings().get("NeedToSet").getAutoDeleteAddressesDelay());
Assert.assertFalse(configuration.getAddressSettings().get("NeedToSet").isEnableMetrics());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isSendToDLAOnNoRoute());
Assert.assertEquals(SlowConsumerThresholdMeasurementUnit.MESSAGES_PER_HOUR, configuration.getAddressSettings().get("NeedToSet").getSlowConsumerThresholdMeasurementUnit());
Assert.assertEquals(900, configuration.getAddressSettings().get("NeedToSet").getQueuePrefetch());
Assert.assertEquals(SimpleString.toSimpleString("iamDeadLetterQueueSuf"), configuration.getAddressSettings().get("NeedToSet").getDeadLetterQueueSuffix());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isDefaultNonDestructive());
Assert.assertEquals(DeletionPolicy.FORCE, configuration.getAddressSettings().get("NeedToSet").getConfigDeleteAddresses());
Assert.assertEquals(10, configuration.getAddressSettings().get("NeedToSet").getSlowConsumerThreshold());
Assert.assertEquals(DeletionPolicy.FORCE, configuration.getAddressSettings().get("NeedToSet").getConfigDeleteQueues());
Assert.assertFalse(configuration.getAddressSettings().get("NeedToSet").isAutoCreateAddresses());
Assert.assertFalse(configuration.getAddressSettings().get("NeedToSet").isAutoDeleteQueues());
Assert.assertEquals(Integer.valueOf(1), configuration.getAddressSettings().get("NeedToSet").getDefaultConsumersBeforeDispatch());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isDefaultPurgeOnNoConsumers());
Assert.assertFalse(configuration.getAddressSettings().get("NeedToSet").isAutoCreateQueues());
Assert.assertFalse(configuration.getAddressSettings().get("NeedToSet").isAutoDeleteAddresses());
Assert.assertEquals(Long.valueOf(77), configuration.getAddressSettings().get("NeedToSet").getDefaultDelayBeforeDispatch());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isAutoDeleteCreatedQueues());
Assert.assertTrue(configuration.getAddressSettings().get("NeedToSet").isDefaultExclusiveQueue());
Assert.assertEquals(Integer.valueOf(10), configuration.getAddressSettings().get("NeedToSet").getDefaultMaxConsumers());
}
@Test

View File

@ -452,7 +452,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
assertEquals(0, conf.getAddressSettings().get("a1").getAutoDeleteQueuesDelay());
assertEquals(0, conf.getAddressSettings().get("a1").getAutoDeleteAddressesDelay());
assertEquals(false, conf.getAddressSettings().get("a1").isDefaultPurgeOnNoConsumers());
assertEquals(5, conf.getAddressSettings().get("a1").getDefaultMaxConsumers());
assertEquals(Integer.valueOf(5), conf.getAddressSettings().get("a1").getDefaultMaxConsumers());
assertEquals(RoutingType.ANYCAST, conf.getAddressSettings().get("a1").getDefaultQueueRoutingType());
assertEquals(RoutingType.MULTICAST, conf.getAddressSettings().get("a1").getDefaultAddressRoutingType());
assertEquals(3, conf.getAddressSettings().get("a1").getDefaultRingSize());
@ -488,7 +488,7 @@ public class FileConfigurationTest extends ConfigurationImplTest {
assertEquals(500, conf.getAddressSettings().get("a2").getAutoDeleteQueuesDelay());
assertEquals(1000, conf.getAddressSettings().get("a2").getAutoDeleteAddressesDelay());
assertEquals(true, conf.getAddressSettings().get("a2").isDefaultPurgeOnNoConsumers());
assertEquals(15, conf.getAddressSettings().get("a2").getDefaultMaxConsumers());
assertEquals(Integer.valueOf(15), conf.getAddressSettings().get("a2").getDefaultMaxConsumers());
assertEquals(RoutingType.MULTICAST, conf.getAddressSettings().get("a2").getDefaultQueueRoutingType());
assertEquals(RoutingType.ANYCAST, conf.getAddressSettings().get("a2").getDefaultAddressRoutingType());
assertEquals(10000, conf.getAddressSettings().get("a2").getDefaultConsumerWindowSize());

View File

@ -51,7 +51,7 @@ public class AddressSettingsTest extends ActiveMQTestBase {
Assert.assertEquals(AddressSettings.DEFAULT_AUTO_CREATE_ADDRESSES, addressSettings.isAutoCreateAddresses());
Assert.assertEquals(AddressSettings.DEFAULT_AUTO_DELETE_ADDRESSES, addressSettings.isAutoDeleteAddresses());
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultPurgeOnNoConsumers(), addressSettings.isDefaultPurgeOnNoConsumers());
Assert.assertEquals(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), addressSettings.getDefaultMaxConsumers());
Assert.assertEquals(Integer.valueOf(ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers()), addressSettings.getDefaultMaxConsumers());
}
@Test