From dev-return-69388-archive-asf-public=cust-asf.ponee.io@activemq.apache.org Fri Jan 25 00:19:46 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id EF91C180771 for ; Fri, 25 Jan 2019 00:19:45 +0100 (CET) Received: (qmail 66264 invoked by uid 500); 24 Jan 2019 23:19:45 -0000 Mailing-List: contact dev-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 dev@activemq.apache.org Received: (qmail 66237 invoked by uid 99); 24 Jan 2019 23:19:44 -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 Jan 2019 23:19:44 +0000 From: GitBox To: dev@activemq.apache.org Subject: [GitHub] michaelandrepearce commented on a change in pull request #2520: ARTEMIS-2238 Enhancement to queueQuery on producer Message-ID: <154837198426.25923.16680270397061253722.gitbox@gitbox.apache.org> Date: Thu, 24 Jan 2019 23:19:44 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit michaelandrepearce commented on a change in pull request #2520: ARTEMIS-2238 Enhancement to queueQuery on producer URL: https://github.com/apache/activemq-artemis/pull/2520#discussion_r250814957 ########## File path: artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageProducer.java ########## @@ -533,6 +499,67 @@ private void doSendx(ActiveMQDestination destination, } } + private void checkDestination(ActiveMQDestination destination, + SimpleString address, + ClientSession clientSession) throws JMSException { + + // TODO: What to do with FQQN + if (!connection.containsKnownDestination(address)) { + try { + ClientSession.AddressQuery addressQuery = clientSession.addressQuery(address); + + boolean addressExists = addressQuery.isExists(); + // first we check the address existence, and autoCreate it if allowed in case it does not exists + + if (!addressExists && addressQuery.isAutoCreateAddresses()) { + + if (destination.isQueue() && !addressQuery.isAutoCreateQueues()) { + if (logger.isDebugEnabled()) { + logger.debug("Address " + address + " was not created because we would not have permission to create queue"); + } + // if it can't create the internal queue on JMS Queues, why bother creating the address, just mark it false now + addressExists = false; + } else { + RoutingType addressType = destination.isQueue() ? RoutingType.ANYCAST : RoutingType.MULTICAST; + clientSession.createAddress(address, addressType, true); + addressExists = true; + } + } + + + // Second we create the queue, but we only do it if the address was created + if (destination.isQueue() && addressExists) { + ClientSession.QueueQuery queueQuery = clientSession.queueQuery(address); + if (!queueQuery.isExists()) { + if (addressQuery.isAutoCreateQueues()) { + try { + if (destination.isTemporary()) { + session.createTemporaryQueue(destination, RoutingType.ANYCAST, address, null, addressQuery); + } else { + session.createQueue(destination, RoutingType.ANYCAST, address, null, true, true, addressQuery); + } + } catch (ActiveMQQueueExistsException thatsOK) { + // nothing to be done + } + } else { + throw new InvalidDestinationException("Queue " + address + " does not exist"); + } + } + } + + if (!addressExists) { Review comment: lets keep that exceptions are thrown from explicit points where checks are done and fail, so can be more explicit and also we can debug where the check fail occured by stack trace lines. ---------------------------------------------------------------- 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