You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by GitBox <gi...@apache.org> on 2019/01/25 00:23:35 UTC

[GitHub] michaelandrepearce commented on a change in pull request #2521: ARTEMIS-2238 Enhancement to queueQuery on producer

michaelandrepearce commented on a change in pull request #2521: ARTEMIS-2238 Enhancement to queueQuery on producer
URL: https://github.com/apache/activemq-artemis/pull/2521#discussion_r250828204
 
 

 ##########
 File path: artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java
 ##########
 @@ -409,33 +409,42 @@ private void doSendx(ActiveMQDestination destination,
                ClientSession.AddressQuery query = clientSession.addressQuery(address);
 
                if (!query.isExists()) {
-                  if (destination.isQueue() && query.isAutoCreateQueues()) {
-                     clientSession.createAddress(address, RoutingType.ANYCAST, true);
-                     if (destination.isTemporary()) {
-                        // TODO is it right to use the address for the queue name here?
-                        session.createTemporaryQueue(destination, RoutingType.ANYCAST, address, null, query);
+                  if (destination.isQueue()) {
+                     if (query.isAutoCreateAddresses() && query.isAutoCreateQueues()) {
+                        clientSession.createAddress(address, RoutingType.ANYCAST, true);
+                        if (destination.isTemporary()) {
+                           // TODO is it right to use the address for the queue name here?
+                           session.createTemporaryQueue(destination, RoutingType.ANYCAST, address, null, query);
+                        } else {
+                           session.createQueue(destination, RoutingType.ANYCAST, address, null, true, true, query);
+                        }
                      } else {
-                        session.createQueue(destination, RoutingType.ANYCAST, address, null, true, true, query);
+                        throw new InvalidDestinationException("JMSQueue " + address + " cannot be created, autoCreateAddresses is " + query.isAutoCreateAddresses() + " , isAutoCreateQueues=" + query.isAutoCreateQueues());
+                     }
+                  } else {
+                     if (query.isAutoCreateAddresses()) {
+                        clientSession.createAddress(address, RoutingType.MULTICAST, true);
+                     } else {
+                        throw new InvalidDestinationException("JMSTopic " + address + " cannot be created, autoCreateAddresses is " + query.isAutoCreateAddresses());
                      }
-                  } else if (!destination.isQueue() && query.isAutoCreateAddresses()) {
-                     clientSession.createAddress(address, RoutingType.MULTICAST, true);
-                  } else if ((destination.isQueue() && !query.isAutoCreateQueues()) || (!destination.isQueue() && !query.isAutoCreateAddresses())) {
-                     throw new InvalidDestinationException("Destination " + address + " does not exist");
                   }
                } else {
                   if (destination.isQueue()) {
                      ClientSession.QueueQuery queueQuery = clientSession.queueQuery(address);
                      if (!queueQuery.isExists()) {
-                        if (destination.isTemporary()) {
-                           session.createTemporaryQueue(destination, RoutingType.ANYCAST, address, null, query);
+                        if (query.isAutoCreateQueues()) {
+                           if (destination.isTemporary()) {
+                              session.createTemporaryQueue(destination, RoutingType.ANYCAST, address, null, query);
+                           } else {
+                              session.createQueue(destination, RoutingType.ANYCAST, address, null, true, true, query);
+                           }
                         } else {
-                           session.createQueue(destination, RoutingType.ANYCAST, address, null, true, true, query);
+                           throw new InvalidDestinationException("JMSQueue " + address + " cannot be created, address exists but autoCreateQueues is " + query.isAutoCreateQueues());
 
 Review comment:
   if we could sort out the exceptions in it, that would be great. its midnight here, will pick up again tomorrow.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services