This is an automated email from the ASF dual-hosted git repository.

clebertsuconic 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 84e68c76e9 ARTEMIS-3771 Avoid not needed lookup for address on 
OpenWire connections
84e68c76e9 is described below

commit 84e68c76e9d1855575dee9cccaeae86342a3583e
Author: AntonRoskvist <[email protected]>
AuthorDate: Thu Apr 21 21:12:27 2022 +0200

    ARTEMIS-3771 Avoid not needed lookup for address on OpenWire connections
---
 .../core/protocol/openwire/OpenWireConnection.java      |  9 ++++++---
 .../artemis/core/protocol/openwire/amq/AMQSession.java  | 17 ++++++++---------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git 
a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
 
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
index 884bf20c33..f033d47159 100644
--- 
a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
+++ 
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java
@@ -66,7 +66,8 @@ import org.apache.activemq.artemis.core.security.SecurityAuth;
 import org.apache.activemq.artemis.core.server.ActiveMQMessageBundle;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.BindingQueryResult;
+import org.apache.activemq.artemis.core.server.AddressQueryResult;
+import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
 import org.apache.activemq.artemis.core.server.ServerSession;
@@ -1149,8 +1150,10 @@ public class OpenWireConnection extends 
AbstractRemotingConnection implements Se
    private void validateDestination(ActiveMQDestination destination) throws 
Exception {
       if (destination.isQueue()) {
          SimpleString physicalName = new 
SimpleString(destination.getPhysicalName());
-         BindingQueryResult result = server.bindingQuery(physicalName);
-         if (!result.isExists() && !result.isAutoCreateQueues()) {
+         QueueQueryResult queue = server.queueQuery(physicalName);
+         AddressQueryResult address = server.addressQuery(physicalName);
+
+         if (!address.isExists() && !queue.isAutoCreateQueues()) {
             throw ActiveMQMessageBundle.BUNDLE.noSuchQueue(physicalName);
          }
       }
diff --git 
a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
 
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
index 1c96519133..3c4b29f2e0 100644
--- 
a/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
+++ 
b/artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java
@@ -41,12 +41,12 @@ import 
org.apache.activemq.artemis.core.protocol.openwire.OpenWireProtocolManage
 import org.apache.activemq.artemis.core.protocol.openwire.util.OpenWireUtil;
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServerLogger;
-import org.apache.activemq.artemis.core.server.BindingQueryResult;
 import org.apache.activemq.artemis.core.server.MessageReference;
 import org.apache.activemq.artemis.core.server.QueueQueryResult;
 import org.apache.activemq.artemis.core.server.ServerConsumer;
 import org.apache.activemq.artemis.core.server.ServerSession;
 import org.apache.activemq.artemis.core.server.SlowConsumerDetectionListener;
+import org.apache.activemq.artemis.core.server.impl.AddressInfo;
 import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
 import org.apache.activemq.artemis.reader.MessageUtil;
 import org.apache.activemq.artemis.spi.core.protocol.SessionCallback;
@@ -225,23 +225,23 @@ public class AMQSession implements SessionCallback {
    }
 
    private boolean checkAutoCreateQueue(SimpleString queueName, boolean 
isTemporary, String filter) throws Exception {
+
       boolean hasQueue = true;
       if (!connection.containsKnownDestination(queueName)) {
-
-         BindingQueryResult bindingQuery = server.bindingQuery(queueName);
-         QueueQueryResult queueBinding = server.queueQuery(queueName);
+         QueueQueryResult queueQuery = server.queueQuery(queueName);
 
          try {
-            if (!queueBinding.isExists()) {
-               if (bindingQuery.isAutoCreateQueues()) {
+            if (!queueQuery.isExists()) {
+               if (queueQuery.isAutoCreateQueues()) {
                   SimpleString queueNameToUse = queueName;
                   SimpleString addressToUse = queueName;
                   RoutingType routingTypeToUse = RoutingType.ANYCAST;
                   if (CompositeAddress.isFullyQualified(queueName.toString())) 
{
                      addressToUse = 
CompositeAddress.extractAddressName(queueName);
                      queueNameToUse = 
CompositeAddress.extractQueueName(queueName);
-                     if (bindingQuery.getAddressInfo() != null) {
-                        routingTypeToUse = 
bindingQuery.getAddressInfo().getRoutingType();
+                     AddressInfo addressInfo = 
server.getAddressInfo(addressToUse);
+                     if (addressInfo != null) {
+                        routingTypeToUse = addressInfo.getRoutingType();
                      } else {
                         AddressSettings as = 
server.getAddressSettingsRepository().getMatch(addressToUse.toString());
                         routingTypeToUse = as.getDefaultAddressRoutingType();
@@ -257,7 +257,6 @@ public class AMQSession implements SessionCallback {
             // In case another thread created the queue before us but after we 
did the binding query
             hasQueue = true;
          }
-
       }
       return hasQueue;
    }

Reply via email to