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

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

                Author: ASF GitHub Bot
            Created on: 27/Jul/21 10:13
            Start Date: 27/Jul/21 10:13
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on a change in pull request #3633:
URL: https://github.com/apache/activemq-artemis/pull/3633#discussion_r677274686



##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/logger/ActiveMQAMQPProtocolMessageBundle.java
##########
@@ -103,5 +103,8 @@
    @Message(id = 119022, value = "The broker connection is trying to connect 
to itself. Check your configuration.", format = Message.Format.MESSAGE_FORMAT)
    ActiveMQBrokerConnectionException brokerConnectionMirrorItself();
 
+   @Message(id = 119023, value = "Sender is missing a remote address for local 
target {0}.", format = Message.Format.MESSAGE_FORMAT)

Review comment:
       Something simpler and more descriptive, say like "Sender link refused 
for address {0}", might be more useful to a user (who isnt necessarily going to 
have much of a clue about 'remote addresses' and 'local targets' or that this 
means the link was refused). More so when augmented with the reason for the 
refusal later (by handling the explaining detach).

##########
File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java
##########
@@ -340,48 +366,74 @@ public void testReconnectAfterSenderOpenTimeout() throws 
Exception {
             x.open();
          });
          serverConnection.receiverOpenHandler((x) -> {
-            if (countOpen.incrementAndGet() > 5) {
-               try {
-                  startFlag.await(10, TimeUnit.SECONDS);
-                  blockBeforeOpen.await(10, TimeUnit.SECONDS);
-               } catch (Throwable ignored) {
+            if (countOpen.incrementAndGet() > 2) {
+               if (countOpen.get() == 3) {
+                  try {
+                     startFlag.await(10, TimeUnit.SECONDS);
+                     blockBeforeOpen.await(10, TimeUnit.SECONDS);
+                     return;
+                  } catch (Throwable ignored) {
+                  }
                }
                HashMap<Symbol, Object> brokerIDProperties = new HashMap<>();
                brokerIDProperties.put(AMQPMirrorControllerSource.BROKER_ID, 
"fake-id");
                x.setProperties(brokerIDProperties);
                x.setOfferedCapabilities(new 
Symbol[]{AMQPMirrorControllerSource.MIRROR_CAPABILITY});
+               x.setTarget(x.getRemoteTarget());
                x.open();
+               x.handler((del, msg) -> {
+                  System.out.println("prefetch = " + x.getPrefetch() + ", Got 
message: " + msg);
+                  if (msg.getApplicationProperties() != null) {
+                     Map map = msg.getApplicationProperties().getValue();
+                     Object value = map.get("sender");
+                     if (value != null && value.equals("jms")) {
+                        messagesReceived.incrementAndGet();

Review comment:
       Rather than sending "jms", sending a unique value on each message and 
recording then later verifying all the received values would seem a better 
check of the actual behaviour.

##########
File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java
##########
@@ -0,0 +1,600 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.CyclicBarrier;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import io.vertx.core.Vertx;
+import io.vertx.proton.ProtonConnection;
+import io.vertx.proton.ProtonServerOptions;
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectConfiguration;
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionAddressType;
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionElement;
+import 
org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPMirrorBrokerConnectionElement;
+import org.apache.activemq.artemis.core.server.ActiveMQServer;
+import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
+import 
org.apache.activemq.artemis.protocol.amqp.broker.ActiveMQProtonRemotingConnection;
+import org.apache.activemq.artemis.protocol.amqp.broker.ProtonProtocolManager;
+import org.apache.activemq.artemis.protocol.amqp.connect.AMQPBrokerConnection;
+import 
org.apache.activemq.artemis.protocol.amqp.connect.mirror.AMQPMirrorControllerSource;
+import 
org.apache.activemq.artemis.tests.integration.amqp.AmqpClientTestSupport;
+import org.apache.activemq.artemis.tests.util.CFUtil;
+import org.apache.activemq.artemis.tests.util.Wait;
+import org.apache.activemq.artemis.utils.collections.ConcurrentHashSet;
+import org.apache.qpid.proton.amqp.Symbol;
+import org.apache.qpid.proton.amqp.transport.AmqpError;
+import org.apache.qpid.proton.amqp.transport.ErrorCondition;
+import org.apache.qpid.proton.amqp.transport.Target;
+import org.apache.qpid.proton.engine.Link;
+import org.apache.qpid.proton.engine.Receiver;
+import org.apache.qpid.proton.engine.impl.ConnectionImpl;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Test;
+
+import static java.util.EnumSet.of;
+import static org.apache.qpid.proton.engine.EndpointState.ACTIVE;
+
+/**
+ * This test will make sure the Broker connection will react accordingly to a 
few misconfigs and possible errors on the network of brokers and eventually 
qipd-dispatch.
+ */
+public class ValidateAMQPErrorsTest extends AmqpClientTestSupport {
+
+   protected static final int AMQP_PORT_2 = 5673;
+
+   protected Vertx vertx;
+
+   protected MockServer mockServer;
+
+   public void startVerx() {
+      vertx = Vertx.vertx();
+   }
+
+   @After
+   public void stop() throws Exception {
+      if (mockServer != null) {
+         mockServer.close();
+         mockServer = null;
+      }
+      if (vertx != null) {
+         try {
+            CountDownLatch latch = new CountDownLatch(1);
+            vertx.close((x) -> latch.countDown());
+            Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
+         } finally {
+            vertx = null;
+         }
+      }
+      AssertionLoggerHandler.stopCapture(); // Just in case startCapture was 
called in any of the tests here
+   }
+
+   @Override
+   protected ActiveMQServer createServer() throws Exception {
+      return createServer(AMQP_PORT, false);
+   }
+
+   /**
+    * Connecting to itself should issue an error.
+    * and the max retry should still be counted, not just keep connecting 
forever.
+    */
+   @Test
+   public void testConnectItself() throws Exception {
+      try {
+         AssertionLoggerHandler.startCapture();
+
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration("test", "tcp://localhost:" + 
AMQP_PORT).setReconnectAttempts(10).setRetryInterval(1);
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server.getConfiguration().addAMQPConnection(amqpConnection);
+
+         server.start();
+
+         Assert.assertEquals(1, server.getBrokerConnections().size());
+         server.getBrokerConnections().forEach((t) -> 
Wait.assertFalse(t::isStarted));
+         Wait.assertTrue(() -> AssertionLoggerHandler.findText("AMQ111001")); 
// max retry
+         AssertionLoggerHandler.clear();
+         Thread.sleep(100);
+         Assert.assertFalse(AssertionLoggerHandler.findText("AMQ111002")); // 
there shouldn't be a retry after the last failure
+         Assert.assertFalse(AssertionLoggerHandler.findText("AMQ111003")); // 
there shouldn't be a retry after the last failure
+      } finally {
+         AssertionLoggerHandler.stopCapture();
+      }
+   }
+
+   @Test
+   public void testCloseLinkOnMirror() throws Exception {
+      try {
+         AssertionLoggerHandler.startCapture();
+
+         ActiveMQServer server2 = createServer(AMQP_PORT_2, false);
+
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration("test", "tcp://localhost:" + 
AMQP_PORT_2).setReconnectAttempts(-1).setRetryInterval(10);
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server.getConfiguration().addAMQPConnection(amqpConnection);
+
+         server.start();
+         Assert.assertEquals(1, server.getBrokerConnections().size());
+         Wait.assertTrue(() -> AssertionLoggerHandler.findText("AMQ111002"));
+         server.getBrokerConnections().forEach((t) -> Wait.assertTrue(() -> 
((AMQPBrokerConnection) t).isConnecting()));
+
+         server2.start();
+
+         server.getBrokerConnections().forEach((t) -> Wait.assertFalse(() -> 
((AMQPBrokerConnection) t).isConnecting()));
+
+         createAddressAndQueues(server);
+
+         Wait.assertTrue(() -> server2.locateQueue(getQueueName()) != null);
+
+         Wait.assertEquals(1, 
server2.getRemotingService()::getConnectionCount);
+         server2.getRemotingService().getConnections().forEach((t) -> {
+            try {
+               ActiveMQProtonRemotingConnection connection = 
(ActiveMQProtonRemotingConnection) t;
+               ConnectionImpl protonConnection = (ConnectionImpl) 
connection.getAmqpConnection().getHandler().getConnection();
+               Wait.waitFor(() -> protonConnection.linkHead(of(ACTIVE), 
of(ACTIVE)) != null);
+               connection.getAmqpConnection().runNow(() -> {
+                  Receiver receiver = (Receiver) 
protonConnection.linkHead(of(ACTIVE), of(ACTIVE));
+                  receiver.close();
+                  connection.flush();
+               });
+            } catch (Exception e) {
+               e.printStackTrace();
+            }
+         });
+
+         ConnectionFactory cf1 = CFUtil.createConnectionFactory("AMQP", 
"tcp://localhost:" + AMQP_PORT);
+         ConnectionFactory cf2 = CFUtil.createConnectionFactory("AMQP", 
"tcp://localhost:" + AMQP_PORT_2);
+
+         try (Connection connection = cf1.createConnection()) {
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = 
session.createProducer(session.createQueue(getQueueName()));
+            for (int i = 0; i < 10; i++) {
+               producer.send(session.createTextMessage("message " + i));
+            }
+         }
+
+         // messages should still flow after a disconnect on the link
+         // the server should reconnect as if it was a failure
+         try (Connection connection = cf2.createConnection()) {
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer consumer = 
session.createConsumer(session.createQueue(getQueueName()));
+            connection.start();
+            for (int i = 0; i < 10; i++) {
+               Assert.assertEquals("message " + i, ((TextMessage) 
consumer.receive(5000)).getText());
+            }
+         }
+
+      } finally {
+         AssertionLoggerHandler.stopCapture();
+      }
+   }
+
+   @Test
+   public void testCloseLinkOnSender() throws Exception {
+      testCloseLink(true);
+   }
+
+   @Test
+   public void testCloseLinkOnReceiver() throws Exception {
+      testCloseLink(false);
+   }
+
+   public void testCloseLink(boolean isSender) throws Exception {
+      try {
+         AssertionLoggerHandler.startCapture();
+
+         ActiveMQServer server2 = createServer(AMQP_PORT_2, false);
+
+         if (isSender) {
+            AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration("test", "tcp://localhost:" + 
AMQP_PORT_2).setReconnectAttempts(-1).setRetryInterval(10);
+            amqpConnection.addElement(new 
AMQPBrokerConnectionElement().setMatchAddress(getQueueName()).setType(AMQPBrokerConnectionAddressType.SENDER));
+            server.getConfiguration().addAMQPConnection(amqpConnection);
+         } else {
+            AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration("test", "tcp://localhost:" + 
AMQP_PORT).setReconnectAttempts(-1).setRetryInterval(10);
+            amqpConnection.addElement(new 
AMQPBrokerConnectionElement().setMatchAddress(getQueueName()).setType(AMQPBrokerConnectionAddressType.RECEIVER));
+            server2.getConfiguration().addAMQPConnection(amqpConnection);
+         }
+
+         if (isSender) {
+            server.start();
+            Assert.assertEquals(1, server.getBrokerConnections().size());
+         } else {
+            server2.start();
+            Assert.assertEquals(1, server2.getBrokerConnections().size());
+         }
+         Wait.assertTrue(() -> AssertionLoggerHandler.findText("AMQ111002"));
+         server.getBrokerConnections().forEach((t) -> Wait.assertTrue(() -> 
((AMQPBrokerConnection) t).isConnecting()));
+
+         if (isSender) {
+            server2.start();
+         } else {
+            server.start();
+         }
+
+         server.getBrokerConnections().forEach((t) -> Wait.assertFalse(() -> 
((AMQPBrokerConnection) t).isConnecting()));
+
+         createAddressAndQueues(server);
+         createAddressAndQueues(server2);
+
+         Wait.assertTrue(() -> server.locateQueue(getQueueName()) != null);
+         Wait.assertTrue(() -> server2.locateQueue(getQueueName()) != null);
+
+         Thread.sleep(1000);
+
+         ActiveMQServer serverReceivingConnections = isSender ? server2 : 
server;
+         Wait.assertEquals(1, 
serverReceivingConnections.getRemotingService()::getConnectionCount);
+         
serverReceivingConnections.getRemotingService().getConnections().forEach((t) -> 
{
+            try {
+               ActiveMQProtonRemotingConnection connection = 
(ActiveMQProtonRemotingConnection) t;
+               ConnectionImpl protonConnection = (ConnectionImpl) 
connection.getAmqpConnection().getHandler().getConnection();
+               Wait.waitFor(() -> protonConnection.linkHead(of(ACTIVE), 
of(ACTIVE)) != null);
+               connection.getAmqpConnection().runNow(() -> {
+                  Link theLink = protonConnection.linkHead(of(ACTIVE), 
of(ACTIVE));
+                  theLink.close();
+                  connection.flush();
+               });
+            } catch (Exception e) {
+               e.printStackTrace();
+            }
+         });
+
+         ConnectionFactory cf1 = CFUtil.createConnectionFactory("AMQP", 
"tcp://localhost:" + AMQP_PORT);
+         ConnectionFactory cf2 = CFUtil.createConnectionFactory("AMQP", 
"tcp://localhost:" + AMQP_PORT_2);
+
+         try (Connection connection = cf1.createConnection()) {
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            MessageProducer producer = 
session.createProducer(session.createQueue(getQueueName()));
+            for (int i = 0; i < 10; i++) {
+               producer.send(session.createTextMessage("message " + i));
+            }
+         }
+
+         // messages should still flow after a disconnect on the link
+         // the server should reconnect as if it was a failure
+         try (Connection connection = cf2.createConnection()) {
+            Session session = connection.createSession(false, 
Session.AUTO_ACKNOWLEDGE);
+            MessageConsumer consumer = 
session.createConsumer(session.createQueue(getQueueName()));
+            connection.start();
+            for (int i = 0; i < 10; i++) {
+               Assert.assertEquals("message " + i, ((TextMessage) 
consumer.receive(5000)).getText());
+            }
+         }
+
+      } finally {
+         AssertionLoggerHandler.stopCapture();
+      }
+   }
+
+   @Test
+   public void testTimeoutOnSenderOpen() throws Exception {
+
+      startVerx();
+
+      ProtonServerOptions serverOptions = new ProtonServerOptions();
+
+      mockServer = new MockServer(vertx, serverOptions, null, serverConnection 
-> {
+         serverConnection.openHandler(serverSender -> {
+            serverConnection.closeHandler(x -> serverConnection.close());
+            serverConnection.open();
+         });
+         serverConnection.sessionOpenHandler((s) -> {
+            s.open();
+         });
+         serverConnection.senderOpenHandler((x) -> {
+            x.open();
+         });
+         serverConnection.receiverOpenHandler((x) -> {
+            //x.open(); // I'm missing the open, so it won't ever connect
+         });
+      });
+
+      try {
+         AssertionLoggerHandler.startCapture();
+
+         AMQPBrokerConnectConfiguration amqpConnection = new 
AMQPBrokerConnectConfiguration("test", "tcp://localhost:" + 
mockServer.actualPort() + 
"?connect-timeout-millis=20").setReconnectAttempts(5).setRetryInterval(10);
+         amqpConnection.addElement(new 
AMQPBrokerConnectionElement().setMatchAddress(getQueueName()).setType(AMQPBrokerConnectionAddressType.SENDER));
+         amqpConnection.addElement(new AMQPMirrorBrokerConnectionElement());
+         server.getConfiguration().addAMQPConnection(amqpConnection);
+         server.start();
+
+         Wait.assertTrue(() -> AssertionLoggerHandler.findText("AMQ111001"));
+
+      } finally {
+         mockServer.close();
+      }
+   }
+
+   @Test
+   public void testReconnectAfterSenderOpenTimeout() throws Exception {
+
+      startVerx();
+
+      ProtonServerOptions serverOptions = new ProtonServerOptions();
+
+      AtomicInteger countOpen = new AtomicInteger(0);
+      CyclicBarrier startFlag = new CyclicBarrier(2);
+      CountDownLatch blockBeforeOpen = new CountDownLatch(1);
+      AtomicInteger disconnects = new AtomicInteger(0);
+      AtomicInteger messagesReceived = new AtomicInteger(0);
+
+      ConcurrentHashSet<ProtonConnection> connections = new 
ConcurrentHashSet<>();
+
+      mockServer = new MockServer(vertx, serverOptions, null, serverConnection 
-> {
+         serverConnection.disconnectHandler(c -> {
+            disconnects.incrementAndGet(); // number of retries
+            connections.remove(c);
+         });
+         serverConnection.openHandler(serverSender -> {
+            serverConnection.closeHandler(x -> {
+               serverConnection.close();
+               connections.remove(serverConnection);
+            });
+            serverConnection.open();
+            connections.add(serverConnection);
+         });
+         serverConnection.sessionOpenHandler((s) -> {
+            s.open();
+         });
+         serverConnection.senderOpenHandler((x) -> {
+            x.open();
+         });
+         serverConnection.receiverOpenHandler((x) -> {
+            if (countOpen.incrementAndGet() > 2) {
+               if (countOpen.get() == 3) {
+                  try {
+                     startFlag.await(10, TimeUnit.SECONDS);
+                     blockBeforeOpen.await(10, TimeUnit.SECONDS);
+                     return;
+                  } catch (Throwable ignored) {
+                  }
+               }
+               HashMap<Symbol, Object> brokerIDProperties = new HashMap<>();
+               brokerIDProperties.put(AMQPMirrorControllerSource.BROKER_ID, 
"fake-id");
+               x.setProperties(brokerIDProperties);
+               x.setOfferedCapabilities(new 
Symbol[]{AMQPMirrorControllerSource.MIRROR_CAPABILITY});
+               x.setTarget(x.getRemoteTarget());
+               x.open();
+               x.handler((del, msg) -> {
+                  System.out.println("prefetch = " + x.getPrefetch() + ", Got 
message: " + msg);
+                  if (msg.getApplicationProperties() != null) {
+                     Map map = msg.getApplicationProperties().getValue();
+                     Object value = map.get("sender");
+                     if (value != null && value.equals("jms")) {
+                        messagesReceived.incrementAndGet();
+                     }
+                  } else {
+                     System.out.println("app properties == null");
+                  }
+                  del.settle();
+                  if (x.getPrefetch() == 0) {
+                     x.flow(1);
+                  }
+               });
+            }
+         });
+      });
+
+      AssertionLoggerHandler.startCapture();

Review comment:
       Oops, it was this one I meant to comment on before that it seemed unused.

##########
File path: 
tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/amqp/connect/ValidateAMQPErrorsTest.java
##########
@@ -340,48 +366,74 @@ public void testReconnectAfterSenderOpenTimeout() throws 
Exception {
             x.open();
          });
          serverConnection.receiverOpenHandler((x) -> {
-            if (countOpen.incrementAndGet() > 5) {
-               try {
-                  startFlag.await(10, TimeUnit.SECONDS);
-                  blockBeforeOpen.await(10, TimeUnit.SECONDS);
-               } catch (Throwable ignored) {
+            if (countOpen.incrementAndGet() > 2) {
+               if (countOpen.get() == 3) {
+                  try {
+                     startFlag.await(10, TimeUnit.SECONDS);
+                     blockBeforeOpen.await(10, TimeUnit.SECONDS);
+                     return;
+                  } catch (Throwable ignored) {
+                  }
                }
                HashMap<Symbol, Object> brokerIDProperties = new HashMap<>();
                brokerIDProperties.put(AMQPMirrorControllerSource.BROKER_ID, 
"fake-id");
                x.setProperties(brokerIDProperties);
                x.setOfferedCapabilities(new 
Symbol[]{AMQPMirrorControllerSource.MIRROR_CAPABILITY});
+               x.setTarget(x.getRemoteTarget());
                x.open();
+               x.handler((del, msg) -> {
+                  System.out.println("prefetch = " + x.getPrefetch() + ", Got 
message: " + msg);
+                  if (msg.getApplicationProperties() != null) {
+                     Map map = msg.getApplicationProperties().getValue();
+                     Object value = map.get("sender");
+                     if (value != null && value.equals("jms")) {
+                        messagesReceived.incrementAndGet();
+                     }
+                  } else {
+                     System.out.println("app properties == null");
+                  }
+                  del.settle();

Review comment:
       A disposition should be applied along with this rather than just 
settling. The reciever doesnt have auto-accept disabled either which makes 
settling manually a bit odd.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java
##########
@@ -570,8 +569,13 @@ private void connectSender(Queue queue,
                      Object remoteBrokerID = 
sender.getRemoteProperties().get(AMQPMirrorControllerSource.BROKER_ID);
                      if (remoteBrokerID.equals(brokerID)) {
                         
error(ActiveMQAMQPProtocolMessageBundle.BUNDLE.brokerConnectionMirrorItself(), 
lastRetryCounter);
+                        return;
                      }
                   }
+                  if (sender.getRemoteTarget() == null) {

Review comment:
       I think this should go first, before the other checks. A refused link 
isnt necessarily going to have other stuff filled out (for example, it wont if 
the broker refuses it due to permissions), but its still going to be the 
refusal thats the issue of concern more than anything else not being there. 
Remove the noted code in that 'test' I added and youll see it starts 
complaining misleadingly about the missing capability, when its the refusal 
that matters.

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/logger/ActiveMQAMQPProtocolMessageBundle.java
##########
@@ -103,5 +103,8 @@
    @Message(id = 119022, value = "The broker connection is trying to connect 
to itself. Check your configuration.", format = Message.Format.MESSAGE_FORMAT)
    ActiveMQBrokerConnectionException brokerConnectionMirrorItself();
 
+   @Message(id = 119023, value = "Sender is missing a remote address for local 
target {0}.", format = Message.Format.MESSAGE_FORMAT)
+   ActiveMQBrokerConnectionException missingRemoteTarget(String address);

Review comment:
       I'd go with something more direct like 'senderLinkRefused' rather than 
'missingRemoteTarget'

##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/connect/AMQPBrokerConnection.java
##########
@@ -570,8 +569,13 @@ private void connectSender(Queue queue,
                      Object remoteBrokerID = 
sender.getRemoteProperties().get(AMQPMirrorControllerSource.BROKER_ID);
                      if (remoteBrokerID.equals(brokerID)) {
                         
error(ActiveMQAMQPProtocolMessageBundle.BUNDLE.brokerConnectionMirrorItself(), 
lastRetryCounter);
+                        return;
                      }
                   }
+                  if (sender.getRemoteTarget() == null) {
+                     
error(ActiveMQAMQPProtocolMessageBundle.BUNDLE.missingRemoteTarget(sender.getTarget().getAddress()),
 lastRetryCounter);

Review comment:
       Is the 'link close listener' still in play? Should it be cleared if it 
is? Otherwise, the expected followup detach frame may lead to a second 
reconnect action being initiated? I wonder if thats exactly what I was seeing 
before, just being caused by the above caps/properties checks (re: my earlier 
comment that I saw the debug test I made fail due to an unexpected total number 
of connections being made to the test server)




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 628336)
    Time Spent: 29.5h  (was: 29h 20m)

> Enhance AMQP Mirror support with dual mirror
> --------------------------------------------
>
>                 Key: ARTEMIS-3243
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3243
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>    Affects Versions: 2.17.0
>            Reporter: Clebert Suconic
>            Assignee: Clebert Suconic
>            Priority: Major
>             Fix For: 2.18.0
>
>          Time Spent: 29.5h
>  Remaining Estimate: 0h
>
> at the current Mirror version, we can only mirror into a single direction.
> With this enhancement the two (or more brokers) would be connected to each 
> other, each one having its own ID, and each one would send updates to the 
> other broker.
> The outcome is that if you just transferred producers and consumers from one 
> broker into the other, the fallback would be automatic and simple. No need to 
> disable and enable mirror options.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to