Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DE870200C48 for ; Thu, 6 Apr 2017 12:39:44 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id DD219160B84; Thu, 6 Apr 2017 10:39:44 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 097BA160B83 for ; Thu, 6 Apr 2017 12:39:43 +0200 (CEST) Received: (qmail 67520 invoked by uid 500); 6 Apr 2017 10:39:43 -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 67509 invoked by uid 99); 6 Apr 2017 10:39:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Apr 2017 10:39:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 5E851C05E9 for ; Thu, 6 Apr 2017 10:39:42 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.98 X-Spam-Level: * X-Spam-Status: No, score=1.98 tagged_above=-999 required=6.31 tests=[HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id cH16fsMuJU77 for ; Thu, 6 Apr 2017 10:39:37 +0000 (UTC) Received: from mail-it0-f49.google.com (mail-it0-f49.google.com [209.85.214.49]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 609FD5FC73 for ; Thu, 6 Apr 2017 10:39:37 +0000 (UTC) Received: by mail-it0-f49.google.com with SMTP id y18so98428587itc.0 for ; Thu, 06 Apr 2017 03:39:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=NNnco1tAEB13qOeAyI1sBSIZNF5L6XWQE7+6YcUB73w=; b=amWT80pun4LFTZ7m+mZjb8WlXWivqVdZL1+2Zm4/TOnefIugNAxE7ax+2k020XZOfF +LLFxfWo9tKNWO3XhJp8aCTq3DEOvkxa0SrRp88te6tYN+WUoyQCP/XBeMYUkX6awP5U GUREneXtj3iruQ/U9iWlZYpK/qT7Vk4NNcO8cvq59oCk7X5gILNnEszJTIyoHsV2eoxW GTjZ7lKT1sUuAxkLd6AxdrDELInTK9uPKcP/hTVPCtBKsNe+Lzeg4pq+IVFtg1mypoOA u0E2dPk6LhPNAaD2JDWQix+UZ4vxoQUgerTvuuhRPCGwUzoiHe0+7wnwLRoSmWLRx8HQ cXaA== X-Gm-Message-State: AFeK/H3zFgPcGC+pfRmAcZV8/PvWzkEwVKjzhAi7EVW+M9H3v+3oFRjt dt+l6U2iV2HhQzj7f+E2qEK+TIyxbqOcgEM= X-Received: by 10.36.84.199 with SMTP id t190mr25381041ita.114.1491475170690; Thu, 06 Apr 2017 03:39:30 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.140.201 with HTTP; Thu, 6 Apr 2017 03:39:30 -0700 (PDT) In-Reply-To: References: From: Martyn Taylor Date: Thu, 6 Apr 2017 11:39:30 +0100 Message-ID: Subject: Re: [DISCUSS] Artemis FQQN(Full Qualified Queue Name) implementation To: dev@activemq.apache.org Content-Type: multipart/alternative; boundary=001a1143ba4cbda421054c7d1f25 archived-at: Thu, 06 Apr 2017 10:39:45 -0000 --001a1143ba4cbda421054c7d1f25 Content-Type: text/plain; charset=UTF-8 Hi Howard, I was going to reply in line, but I think there's a fundamental assumption you've made that's caused some confusion], so I'll reply here. The purpose of FQQN is not to change the uniqueness of queue names across addresses. Each queue must have a globally unique name. Instead, the change is required as we've adopted a new addressing model, that creates consistency across all the protocols. In order to make this happen, a client wanting to connect to a queue with name "foo" with address "address", no longer subscribes to the queue name, it actually subscribes to the "address". This is where the ANYCAST and MULTICAST routing types fit in. To define queue like behaviour on the broker for an address "address". You define the following:
1 queue), we require that the queue name match the address. So for JMS you currently need to define you queue like this:
.... There are other use cases in the documentation, so I'll not repeat here. Long story short, you don't need to add any complex logic to handle the "non uniqueness" of queue names. Just parse the FQQN in the OpenWire protocol, get the queue and address part, then do normal queue lookup on the broker. This has already been implemented for AMQP, look at the ProtonServerSender/ReceiverContext for examples. Cheers On Thu, Apr 6, 2017 at 4:41 AM, Howard Gao wrote: > So I've been doing this FQQN support (ARTEMIS-1093) and I'd like > to share my thoughts and current implementations of key functionalities, > as well as some concerns. I'd appreciate any comments > and adivces to make it better. > > More details about FQQN concepts please see official doc: > https://github.com/apache/activemq-artemis/blob/master/ > docs/user-manual/en/address-model.md#fully-qualified-queue-names > > Simply put, a FQQN takes form of
::. It uniquely > and explicitly identifies a 'queue' entity within a broker. With FQQN > any clients can have access to any 'core' queues, so long as the addresses > and queue names are known to them. > > For example, if a core queue "q1" is deployed on address "address1", its > FQQN would be "address1::q1". A JMS consumer can receive messages that > routed > to "q1" by referencing the queue directly using its FQQN, as illustrated > in the following code snippet: > > ... > Queue q1 = session.createQueue("address1::q1"); > MessageConsumer consumer1 = session.createConsumer(q1); > Message m = consumer1.receive(2000); > ... > > Before FQQN, clients using any protocols only can access a queue by its > name, which must be unique across all addresses within a broker. If we > implement FQQN based on this uniqueness restriction, we don't need change > any internal bindings management code. Simply removing the address prefix > (like "address1::" in FQQN "address1::q1") from client requests and every > thing would work just fine. > > However, with FQQN in place it is possible that queues of same names can be > created on different addresses while still won't lose their uniqueness. > For example, "address1::q1" and "address2::q1" are two distinct queues and > can perfectly live within a broker together. In this case, a client trying > to access one of the queues can't just simply specify the queue name "q1". > Because the broker wouldn't know which queue it refers to (ambiguity). > > To solve this issue, I need to add some 'extra' logic to the existing > binding management. Here is what I do: > (PR: https://github.com/apache/activemq-artemis/pull/1172 ) > 1. Inside broker it used a map (SimpleAddressManager.nameMap) to store > bindings (queues) and the keys are queue names. As queue names will no > longer be guaranteed to be unique with FQQN, a composite key (BindingKey) > is introduced so that the address part of the queues will paticipate in > key 'hash' and 'equals' calculation. > 2. In order to detect 'ambiguous' binding queries, a new map called > uniqueNameMap is added to SimpleAddressManager to keep the number of > addresses a binding is bound to. For example if a queue "q1" is bound to > both addresses "address1" and "address2", the number stored in this map for > "q1" is 2 ("q1"->2). > > When a binding is added these two maps gets updated. > To understand how it works consider the following scenarios: > > In all of the scenarios below suppose the broker have 3 queues > "address1::q1", "address1::q2", "address2::q1" > > [Scenario 1] A client comes in requesting access to a queue by its name > "q2". > Broker first checks the uniqueNameMap and finds that there is only > one binding for this queue name, no ambiguity, and it goes ahead to > get the binding from nameMap and returns it. > > [Scenario 2] A client comes in requesting access to a queue by its FQQN > "address2::q1". Because FQQN is used we don't need to check ambiguity > this time. it therefore goes directly to find the binding in nameMap > and returns it. > > [Scenario 3] A client comes in requesting access to a queue by its name > "q1". > Because there are two bindings (queues) bound to different addresses and > client doesn't use FQQN, broker checks the uniqueNameMap and finds that > there are more than one (two in this case) bindings exists by the same > queue name, in which case it can't determine which one is the one needed. > So it gives a warning message and returns null result. > > Some concerns with my implementation: > > 1) Although the logic seems straightforward, but the actual code looks > like a bit too complex, as some folks pointed out. I'm currently seeking > a way to make it simple. Probably separating it into smaller tasks? > > 2) String manipulations (like concat() and String/SimpleString conversions) > added performance cost. Need a way to minimize the impact. > > Again any comments are welcomed. > > Thanks, > Howard > --001a1143ba4cbda421054c7d1f25--