From commits-return-63618-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Thu Jun 24 20:36:37 2021 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mxout1-ec2-va.apache.org (mxout1-ec2-va.apache.org [3.227.148.255]) by mx-eu-01.ponee.io (Postfix) with ESMTPS id 299D2180648 for ; Thu, 24 Jun 2021 22:36:37 +0200 (CEST) Received: from mail.apache.org (mailroute1-lw-us.apache.org [207.244.88.153]) by mxout1-ec2-va.apache.org (ASF Mail Server at mxout1-ec2-va.apache.org) with SMTP id 64D453EDA0 for ; Thu, 24 Jun 2021 20:36:36 +0000 (UTC) Received: (qmail 83283 invoked by uid 500); 24 Jun 2021 20:36:36 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 83274 invoked by uid 99); 24 Jun 2021 20:36:35 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Jun 2021 20:36:35 +0000 Received: by gitbox.apache.org (ASF Mail Server at gitbox.apache.org, from userid 33) id C2C19821E0; Thu, 24 Jun 2021 20:36:35 +0000 (UTC) Date: Thu, 24 Jun 2021 20:36:35 +0000 To: "commits@activemq.apache.org" Subject: [activemq-artemis] branch main updated: ARTEMIS-3366 deleteAddress can remove SnF queue MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Message-ID: <162456699548.14547.1225694001252732365@gitbox.apache.org> From: jbertram@apache.org X-Git-Host: gitbox.apache.org X-Git-Repo: activemq-artemis X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Oldrev: 8b33279667f9f9faabc45dc82d0999625c0b5c7d X-Git-Newrev: 45ae64a01c803d35e8dbce41c543d5dce984416a X-Git-Rev: 45ae64a01c803d35e8dbce41c543d5dce984416a X-Git-NotificationType: ref_changed_plus_diff X-Git-Multimail-Version: 1.5.dev Auto-Submitted: auto-generated This is an automated email from the ASF dual-hosted git repository. jbertram pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git The following commit(s) were added to refs/heads/main by this push: new 45ae64a ARTEMIS-3366 deleteAddress can remove SnF queue new 0275630 This closes #3636 45ae64a is described below commit 45ae64a01c803d35e8dbce41c543d5dce984416a Author: Justin Bertram AuthorDate: Thu Jun 24 13:10:48 2021 -0500 ARTEMIS-3366 deleteAddress can remove SnF queue --- .../core/postoffice/impl/PostOfficeImpl.java | 7 ++- .../distribution/SimpleSymmetricClusterTest.java | 57 ++++++++++++++++++++++ 2 files changed, 62 insertions(+), 2 deletions(-) diff --git a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java index 95e2b7e..acb897c 100644 --- a/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java +++ b/artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/PostOfficeImpl.java @@ -79,6 +79,7 @@ import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.QueueFactory; import org.apache.activemq.artemis.core.server.RouteContextList; import org.apache.activemq.artemis.core.server.RoutingContext; +import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding; import org.apache.activemq.artemis.core.server.group.GroupingHandler; import org.apache.activemq.artemis.core.server.impl.AckReason; import org.apache.activemq.artemis.core.server.impl.AddressInfo; @@ -815,8 +816,10 @@ public class PostOfficeImpl implements PostOffice, NotificationListener, Binding final Collection bindingsForAddress = getDirectBindings(address); if (force) { for (Binding binding : bindingsForAddress) { - if (binding instanceof QueueBinding) { - ((QueueBinding)binding).getQueue().deleteQueue(true); + if (binding instanceof LocalQueueBinding) { + ((LocalQueueBinding)binding).getQueue().deleteQueue(true); + } else if (binding instanceof RemoteQueueBinding) { + removeBinding(binding.getUniqueName(), null, true); } } diff --git a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java index fcadf9e..c9f2c6f 100644 --- a/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java +++ b/tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/cluster/distribution/SimpleSymmetricClusterTest.java @@ -16,6 +16,11 @@ */ package org.apache.activemq.artemis.tests.integration.cluster.distribution; +import java.util.Collection; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.core.postoffice.Binding; +import org.apache.activemq.artemis.core.server.cluster.RemoteQueueBinding; import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.jboss.logging.Logger; import org.junit.Ignore; @@ -121,6 +126,58 @@ public class SimpleSymmetricClusterTest extends ClusterTestBase { } @Test + public void testDeleteAddress() throws Exception { + final String ADDRESS = "queues.testaddress"; + + setupServer(0, true, isNetty()); + setupServer(1, true, isNetty()); + + setupClusterConnection("cluster0", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 0, 1); + setupClusterConnection("cluster1", "queues", MessageLoadBalancingType.ON_DEMAND, 1, isNetty(), 1, 0); + + startServers(0, 1); + + waitForTopology(servers[0], 2); + waitForTopology(servers[1], 2); + + setupSessionFactory(0, isNetty()); + setupSessionFactory(1, isNetty()); + + createQueue(0, ADDRESS, "queue0", null, false); + createQueue(1, ADDRESS, "queue0", null, false); + + addConsumer(0, 0, "queue0", null); + addConsumer(1, 1, "queue0", null); + + waitForBindings(0, ADDRESS, 1, 1, true); + waitForBindings(1, ADDRESS, 1, 1, true); + + waitForBindings(0, ADDRESS, 1, 1, false); + waitForBindings(1, ADDRESS, 1, 1, false); + + // there should be both a local and a remote binding + Collection bindings = servers[0].getPostOffice().getDirectBindings(SimpleString.toSimpleString(ADDRESS)); + assertEquals(2, bindings.size()); + + // the remote binding should point to the SnF queue + SimpleString snf = null; + for (Binding binding : bindings) { + if (binding instanceof RemoteQueueBinding) { + snf = ((RemoteQueueBinding)binding).getQueue().getName(); + } + } + assertNotNull(snf); + assertNotNull(servers[0].locateQueue(snf)); + + servers[0].getActiveMQServerControl().deleteAddress(ADDRESS, true); + + // no bindings should remain but the SnF queue should still be there + bindings = servers[0].getPostOffice().getDirectBindings(SimpleString.toSimpleString(ADDRESS)); + assertEquals(0, bindings.size()); + assertNotNull(servers[0].locateQueue(snf)); + } + + @Test public void testSimple_TwoNodes() throws Exception { setupServer(0, false, isNetty()); setupServer(1, false, isNetty());