activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clebertsuco...@apache.org
Subject [2/2] activemq-artemis git commit: ARTEMIS-1688 fix cluster when auto-create-addresses=false
Date Tue, 20 Feb 2018 16:20:17 GMT
ARTEMIS-1688 fix cluster when auto-create-addresses=false


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/ab602351
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/ab602351
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/ab602351

Branch: refs/heads/master
Commit: ab602351a1ef87a77e665b769bb0acaa3e709817
Parents: 3c7d57c
Author: Justin Bertram <jbertram@apache.org>
Authored: Mon Feb 19 18:46:32 2018 -0600
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Tue Feb 20 11:19:55 2018 -0500

----------------------------------------------------------------------
 .../core/server/ActiveMQServerLogger.java       |  4 ++
 .../management/impl/ManagementServiceImpl.java  | 28 +++++++++++++
 .../distribution/SymmetricClusterTest.java      | 42 ++++++++++++++++++++
 3 files changed, 74 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab602351/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
index 10c827e..8bc24f8 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/ActiveMQServerLogger.java
@@ -1578,6 +1578,10 @@ public interface ActiveMQServerLogger extends BasicLogger {
    @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);

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab602351/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
----------------------------------------------------------------------
diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
index 9b9830a..24a30bf 100644
--- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
+++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/server/management/impl/ManagementServiceImpl.java
@@ -69,6 +69,7 @@ import org.apache.activemq.artemis.core.postoffice.PostOffice;
 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;
@@ -540,6 +541,33 @@ public class ManagementServiceImpl implements ManagementService {
       }
 
       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

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/ab602351/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java
----------------------------------------------------------------------
diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java
b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java
index ca4554f..79b2d00 100644
--- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java
+++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SymmetricClusterTest.java
@@ -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;
@@ -230,6 +234,44 @@ public class SymmetricClusterTest extends ClusterTestBase {
    }
 
    @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");
       setupCluster();


Mime
View raw message