ARTEMIS-1925 - fix test regression - isHighAcceptPriority does not need to check for off_with_redistribution

This commit is contained in:
gtully 2021-11-01 12:33:50 +00:00 committed by Gary Tully
parent 1839461204
commit c6b85ea4e3
3 changed files with 37 additions and 2 deletions

View File

@ -154,7 +154,7 @@ public class RemoteQueueBindingImpl implements RemoteQueueBinding {
@Override
public synchronized boolean isHighAcceptPriority(final Message message) {
if (consumerCount == 0 || messageLoadBalancingType.equals(MessageLoadBalancingType.OFF) || messageLoadBalancingType.equals(MessageLoadBalancingType.OFF_WITH_REDISTRIBUTION)) {
if (consumerCount == 0 || messageLoadBalancingType.equals(MessageLoadBalancingType.OFF)) {
return false;
}

View File

@ -764,6 +764,36 @@ public class MessageRedistributionTest extends ClusterTestBase {
verifyNotReceive(1);
}
@Test
public void testRedistributionOnlyWhenLocalRemovedLbOffWithRedistribution() throws Exception {
setupCluster(MessageLoadBalancingType.OFF_WITH_REDISTRIBUTION);
startServers(0, 1);
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
createQueue(0, "queues.testaddress", "queue0", null, false);
createQueue(1, "queues.testaddress", "queue0", null, false);
addConsumer(0, 0, "queue0", null);
addConsumer(1, 1, "queue0", null);
waitForBindings(0, "queues.testaddress", 1, 1, true);
waitForBindings(1, "queues.testaddress", 1, 1, true);
waitForBindings(0, "queues.testaddress", 1, 1, false);
waitForBindings(1, "queues.testaddress", 1, 1, false);
send(0, "queues.testaddress", 2, false, null);
verifyNotReceive(1);
removeConsumer(0);
verifyReceiveAll(2, 1);
}
@Test
public void testBackAndForth() throws Exception {
for (int i = 0; i < 10; i++) {

View File

@ -93,9 +93,14 @@ public class RemoteQueueBindImplTest extends ActiveMQTestBase {
final SimpleString bridgeName = RandomUtil.randomSimpleString();
final int distance = 0;
RemoteQueueBindingImpl bindingOff = new RemoteQueueBindingImpl(id, address, uniqueName, routingName, remoteQueueID, filterString, storeAndForwardQueue, bridgeName, distance, MessageLoadBalancingType.OFF);
bindingOff.addConsumer(null);
assertFalse(bindingOff.isHighAcceptPriority(null));
RemoteQueueBindingImpl bindingOffWithRedistribution = new RemoteQueueBindingImpl(id, address, uniqueName, routingName, remoteQueueID, filterString, storeAndForwardQueue, bridgeName, distance, MessageLoadBalancingType.OFF_WITH_REDISTRIBUTION);
assertFalse(bindingOffWithRedistribution.isHighAcceptPriority(null));
bindingOffWithRedistribution.addConsumer(null);
// not really intuitive, but via getNextBinding (initial routing) BindingsImpl.matchBinding() traps remote bindings
// with OFF_WITH_REDISTRIBUTION which makes the need for change in isHighAcceptPriority redundant
// and ensures that redistribution can occur as isHighAcceptPriority is invoked from redistribute
assertTrue(bindingOffWithRedistribution.isHighAcceptPriority(null));
}
}