[ 
https://issues.apache.org/jira/browse/ARTEMIS-5037?focusedWorklogId=934643&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-934643
 ]

ASF GitHub Bot logged work on ARTEMIS-5037:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 13/Sep/24 07:44
            Start Date: 13/Sep/24 07:44
    Worklog Time Spent: 10m 
      Work Description: lavocatt commented on code in PR #5220:
URL: https://github.com/apache/activemq-artemis/pull/5220#discussion_r1758353666


##########
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/AMQPSquareMirroringTest.java:
##########
@@ -0,0 +1,278 @@
+/*
+ * 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.amqp.connect;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+import javax.jms.MessageConsumer;
+import javax.jms.MessageProducer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
+
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectConfiguration;
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPMirrorBrokerConnectionElement;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.core.server.Queue;
+import 
org.apache.activemq.artemis.tests.integration.amqp.AmqpClientTestSupport;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.utils.Wait;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+
+public class AMQPSquareMirroringTest extends AmqpClientTestSupport {
+
+   protected static final int AMQP_PORT_2 = 5673;
+   protected static final int AMQP_PORT_3 = 5674;
+   protected static final int AMQP_PORT_4 = 5675;
+
+   ActiveMQServer server_2;
+   ActiveMQServer server_3;
+   ActiveMQServer server_4;
+
+   @Override
+   protected ActiveMQServer createServer() throws Exception {
+      return createServer(AMQP_PORT, false);
+   }
+
+   @Test
+   public void testSquare() throws Exception {
+      server_2 = createServer(AMQP_PORT_2, false);
+      server_3 = createServer(AMQP_PORT_3, false);
+      server_4 = createServer(AMQP_PORT_4, false);
+
+      // name the servers, for convenience during debugging
+      server.getConfiguration().setName("1");
+      server_2.getConfiguration().setName("2");
+      server_3.getConfiguration().setName("3");
+      server_4.getConfiguration().setName("4");
+
+      /**
+       *
+       * Setup the mirroring topology to be a square:
+       *
+       * 1 <- - -> 2
+       * ^         ^       The link between 1 and 2 and the
+       * |         |       link between 3 and 4 are noForward
+       * v         v       links in both directions.
+       * 4 <- - -> 3
+       */
+
+      {
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "1to2", "tcp://localhost:" 
+ AMQP_PORT_2).setRetryInterval(100);
+         amqpConnection.addElement(new 
AMQPMirrorBrokerConnectionElement().setCanForwardMessages(false));
+         server.getConfiguration().addAMQPConnection(amqpConnection);
+         amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "1to4", "tcp://localhost:" 
+ AMQP_PORT_4).setRetryInterval(100);
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server.getConfiguration().addAMQPConnection(amqpConnection);
+      }
+
+      {
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "2to1", "tcp://localhost:" 
+ AMQP_PORT).setRetryInterval(100);
+         amqpConnection.addElement(new 
AMQPMirrorBrokerConnectionElement().setCanForwardMessages(false));
+         server_2.getConfiguration().addAMQPConnection(amqpConnection);
+         amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "2to3", "tcp://localhost:" 
+ AMQP_PORT_3).setRetryInterval(100);
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server_2.getConfiguration().addAMQPConnection(amqpConnection);
+      }
+
+      {
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "3to2", "tcp://localhost:" 
+ AMQP_PORT_2).setRetryInterval(100);
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server_3.getConfiguration().addAMQPConnection(amqpConnection);
+         amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "3to4", "tcp://localhost:" 
+ AMQP_PORT_4).setRetryInterval(100);
+         amqpConnection.addElement(new 
AMQPMirrorBrokerConnectionElement().setCanForwardMessages(false));
+         server_3.getConfiguration().addAMQPConnection(amqpConnection);
+      }
+
+      {
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "4to1", "tcp://localhost:" 
+ AMQP_PORT).setRetryInterval(100);
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server_4.getConfiguration().addAMQPConnection(amqpConnection);
+         amqpConnection = new 
AMQPBrokerConnectConfiguration(getTestMethodName() + "4to3", "tcp://localhost:" 
+ AMQP_PORT_3).setRetryInterval(100);
+         amqpConnection.addElement(new 
AMQPMirrorBrokerConnectionElement().setCanForwardMessages(false));
+         server_4.getConfiguration().addAMQPConnection(amqpConnection);
+      }
+
+      server.start();
+      server_2.start();
+      server_3.start();
+      server_4.start();
+
+      createAddressAndQueues(server);
+      Wait.assertTrue(() -> server.locateQueue(getQueueName()) != null);
+      Wait.assertTrue(() -> server_2.locateQueue(getQueueName()) != null);
+      Wait.assertTrue(() -> server_3.locateQueue(getQueueName()) != null);
+      Wait.assertTrue(() -> server_4.locateQueue(getQueueName()) != null);
+
+      Queue q1 = server.locateQueue(getQueueName());
+      assertNotNull(q1);
+
+      Queue q2 = server.locateQueue(getQueueName());
+      assertNotNull(q2);
+
+      Queue q3 = server.locateQueue(getQueueName());
+      assertNotNull(q3);
+
+      Queue q4 = server.locateQueue(getQueueName());
+      assertNotNull(q4);
+
+      ConnectionFactory factory = CFUtil.createConnectionFactory("AMQP", 
"tcp://localhost:" + AMQP_PORT);

Review Comment:
   I tried to use a `randomProtocol()`:
   
![image](https://github.com/user-attachments/assets/e62e6394-0055-44f2-9bb3-64d4e6101e53)
   
   and then this error happened: 
   
![image](https://github.com/user-attachments/assets/6d269d66-18f4-48ed-ada5-d19b7ced6052)
   
   Any idea on what could be going on?
   





Issue Time Tracking
-------------------

    Worklog Id:     (was: 934643)
    Time Spent: 1h 40m  (was: 1.5h)

> AMQ Broker Mirroring: One to Many - avoid the infinite loop of the messages
> ---------------------------------------------------------------------------
>
>                 Key: ARTEMIS-5037
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-5037
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Thomas Lavocat
>            Assignee: Thomas Lavocat
>            Priority: Major
>          Time Spent: 1h 40m
>  Remaining Estimate: 0h
>
> AMQ Broker Mirroring: One to Many - avoid the infinite loop of the messages:
> if we have a->b-c->a..
> a message will circulate forever in the mirrors



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact


Reply via email to