Skip to content

Commit

Permalink
ARTEMIS-1688 fix cluster when auto-create-addresses=false
Browse files Browse the repository at this point in the history
  • Loading branch information
jbertram authored and clebertsuconic committed Feb 20, 2018
1 parent 3c7d57c commit ab60235
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
Expand Up @@ -1578,6 +1578,10 @@ void slowConsumerDetected(String sessionID,
@Message(id = 222269, value = "Please use a fixed value for \"journal-pool-files\". Default changed per https://issues.apache.org/jira/browse/ARTEMIS-1628", format = Message.Format.MESSAGE_FORMAT)
void useFixedValueOnJournalPoolFiles();

@LogMessage(level = Logger.Level.WARN)
@Message(id = 222270, value = "Unable to create management notification address: {0}", format = Message.Format.MESSAGE_FORMAT)
void unableToCreateManagementNotificationAddress(SimpleString addressName, @Cause Exception e);

@LogMessage(level = Logger.Level.ERROR)
@Message(id = 224000, value = "Failure in initialisation", format = Message.Format.MESSAGE_FORMAT)
void initializationError(@Cause Throwable e);
Expand Down
Expand Up @@ -69,6 +69,7 @@
import org.apache.activemq.artemis.core.remoting.server.RemotingService;
import org.apache.activemq.artemis.core.security.Role;
import org.apache.activemq.artemis.core.security.SecurityStore;
import org.apache.activemq.artemis.core.server.ActivateCallback;
import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
Expand Down Expand Up @@ -540,6 +541,33 @@ public void start() throws Exception {
}

started = true;

/**
* Ensure the management notification address is created otherwise if auto-create-address = false then cluster
* bridges won't be able to connect.
*/
messagingServer.registerActivateCallback(new ActivateCallback() {
@Override
public void preActivate() {
}

@Override
public void activated() {
try {
messagingServer.addAddressInfo(new AddressInfo(managementNotificationAddress, RoutingType.MULTICAST));
} catch (Exception e) {
ActiveMQServerLogger.LOGGER.unableToCreateManagementNotificationAddress(managementNotificationAddress, e);
}
}

@Override
public void deActivate() {
}

@Override
public void activationComplete() {
}
});
}

@Override
Expand Down
Expand Up @@ -16,7 +16,11 @@
*/
package org.apache.activemq.artemis.tests.integration.cluster.distribution;

import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Before;
Expand Down Expand Up @@ -229,6 +233,44 @@ public void testBasicRoundRobinManyMessages() throws Exception {
verifyNotReceive(0, 1, 2, 3, 4);
}

@Test
public void testBasicRoundRobinManyMessagesNoAddressAutoCreate() throws Exception {
setupCluster();

startServers();

for (int i = 0; i < 5; i++) {
servers[i].getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
}

for (int i = 0; i < 5; i++) {
setupSessionFactory(i, isNetty());
}

for (int i = 0; i < 5; i++) {
servers[i].addAddressInfo(new AddressInfo(SimpleString.toSimpleString("queues.testaddress"), RoutingType.MULTICAST));
createQueue(i, "queues.testaddress", "queue0", null, false);
}

for (int i = 0; i < 5; i++) {
addConsumer(i, i, "queue0", null);
}

for (int i = 0; i < 5; i++) {
waitForBindings(i, "queues.testaddress", 1, 1, true);
}

for (int i = 0; i < 5; i++) {
waitForBindings(i, "queues.testaddress", 4, 4, false);
}

send(0, "queues.testaddress", 1000, true, null);

verifyReceiveRoundRobinInSomeOrder(1000, 0, 1, 2, 3, 4);

verifyNotReceive(0, 1, 2, 3, 4);
}

@Test
public void testRoundRobinMultipleQueues() throws Exception {
SymmetricClusterTest.log.info("starting");
Expand Down

0 comments on commit ab60235

Please sign in to comment.