This commit is contained in:
Clebert Suconic 2018-10-10 18:45:40 -04:00
commit 8edd9399d2
2 changed files with 111 additions and 1 deletions

View File

@ -408,11 +408,29 @@ public final class BindingsImpl implements Bindings {
}
if (messageLoadBalancingType.equals(MessageLoadBalancingType.OFF) && theBinding instanceof RemoteQueueBinding) {
theBinding = getNextBinding(message, routingName, bindings);
if (exclusivelyRemote(bindings)) {
theBinding = null;
} else {
theBinding = getNextBinding(message, routingName, bindings);
}
}
return theBinding;
}
private boolean exclusivelyRemote(List<Binding> bindings) {
boolean result = true;
for (Binding binding : bindings) {
if (!(binding instanceof RemoteQueueBinding)) {
result = false;
break;
}
}
return result;
}
private void routeUsingStrictOrdering(final Message message,
final RoutingContext context,
final GroupingHandler groupingGroupingHandler,

View File

@ -0,0 +1,92 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.tests.integration.cluster.distribution;
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.junit.Before;
import org.junit.Test;
public class RemoteBindingWithoutLoadBalancingTest extends ClusterTestBase {
private static final IntegrationTestLogger log = IntegrationTestLogger.LOGGER;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
setupServers();
}
protected boolean isNetty() {
return false;
}
/**
* It's possible that when a cluster has disabled message load balancing then a message
* sent to a node that only has a corresponding remote queue binding will trigger a
* stack overflow.
*/
@Test
public void testStackOverflow() throws Exception {
setupCluster();
startServers();
setupSessionFactory(0, isNetty());
setupSessionFactory(1, isNetty());
createQueue(0, "queues.testaddress", "queue0", null, false);
waitForBindings(0, "queues.testaddress", 1, 0, true);
waitForBindings(1, "queues.testaddress", 1, 0, false);
send(1, "queues.testaddress", 1, false, null);
}
protected void setupCluster() throws Exception {
setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.OFF, 1, isNetty(), 0, 1);
setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.OFF, 1, isNetty(), 1, 0);
}
protected void setupServers() throws Exception {
setupServer(0, isFileStorage(), isNetty());
setupServer(1, isFileStorage(), isNetty());
}
protected void startServers() throws Exception {
startServers(0, 1);
}
protected void stopServers() throws Exception {
closeAllConsumers();
closeAllSessionFactories();
closeAllServerLocatorsFactories();
stopServers(0, 1);
}
@Override
protected boolean isFileStorage() {
return false;
}
}