ARTEMIS-2638 retro resources created recursively w/# match

This commit is contained in:
Justin Bertram 2020-03-05 21:00:15 -06:00
parent 2a7320bffd
commit ea09a0fd39
2 changed files with 13 additions and 4 deletions

View File

@ -466,7 +466,7 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding
server.callBrokerAddressPlugins(plugin -> plugin.afterAddAddress(addressInfo, reload)); server.callBrokerAddressPlugins(plugin -> plugin.afterAddAddress(addressInfo, reload));
} }
long retroactiveMessageCount = addressSettingsRepository.getMatch(addressInfo.getName().toString()).getRetroactiveMessageCount(); long retroactiveMessageCount = addressSettingsRepository.getMatch(addressInfo.getName().toString()).getRetroactiveMessageCount();
if (retroactiveMessageCount > 0) { if (retroactiveMessageCount > 0 && !addressInfo.isInternal() && !ResourceNames.isRetroactiveResource(server.getInternalNamingPrefix(), addressInfo.getName())) {
createRetroactiveResources(addressInfo.getName(), retroactiveMessageCount, reload); createRetroactiveResources(addressInfo.getName(), retroactiveMessageCount, reload);
} }
if (ResourceNames.isRetroactiveResource(server.getInternalNamingPrefix(), addressInfo.getName())) { if (ResourceNames.isRetroactiveResource(server.getInternalNamingPrefix(), addressInfo.getName())) {

View File

@ -100,13 +100,22 @@ public class RetroactiveAddressTest extends ActiveMQTestBase {
} }
@Test @Test
public void testRetroactiveResourceCreation() throws Exception { public void testRetroactiveResourceCreationWithExactMatch() throws Exception {
final SimpleString addressName = SimpleString.toSimpleString("myAddress"); internalTestRetroactiveResourceCreation("myAddress", "myAddress");
}
@Test
public void testRetroactiveResourceCreationWithWildcardMatch() throws Exception {
internalTestRetroactiveResourceCreation("myAddress", "#");
}
private void internalTestRetroactiveResourceCreation(String address, String match) throws Exception {
final SimpleString addressName = SimpleString.toSimpleString(address);
final SimpleString divertAddress = ResourceNames.getRetroactiveResourceAddressName(internalNamingPrefix, delimiter, addressName); final SimpleString divertAddress = ResourceNames.getRetroactiveResourceAddressName(internalNamingPrefix, delimiter, addressName);
final SimpleString divertMulticastQueue = ResourceNames.getRetroactiveResourceQueueName(internalNamingPrefix, delimiter, addressName, RoutingType.MULTICAST); final SimpleString divertMulticastQueue = ResourceNames.getRetroactiveResourceQueueName(internalNamingPrefix, delimiter, addressName, RoutingType.MULTICAST);
final SimpleString divertAnycastQueue = ResourceNames.getRetroactiveResourceQueueName(internalNamingPrefix, delimiter, addressName, RoutingType.ANYCAST); final SimpleString divertAnycastQueue = ResourceNames.getRetroactiveResourceQueueName(internalNamingPrefix, delimiter, addressName, RoutingType.ANYCAST);
final SimpleString divert = ResourceNames.getRetroactiveResourceDivertName(internalNamingPrefix, delimiter, addressName); final SimpleString divert = ResourceNames.getRetroactiveResourceDivertName(internalNamingPrefix, delimiter, addressName);
server.getAddressSettingsRepository().addMatch(addressName.toString(), new AddressSettings().setRetroactiveMessageCount(10)); server.getAddressSettingsRepository().addMatch(match, new AddressSettings().setRetroactiveMessageCount(10));
server.addAddressInfo(new AddressInfo(addressName)); server.addAddressInfo(new AddressInfo(addressName));
assertNotNull(server.getAddressInfo(divertAddress)); assertNotNull(server.getAddressInfo(divertAddress));
assertNotNull(server.locateQueue(divertMulticastQueue)); assertNotNull(server.locateQueue(divertMulticastQueue));