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 80973200C81 for ; Fri, 26 May 2017 17:12:37 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 7F5DC160BB8; Fri, 26 May 2017 15:12:37 +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 99E9E160BAF for ; Fri, 26 May 2017 17:12:36 +0200 (CEST) Received: (qmail 86591 invoked by uid 500); 26 May 2017 15:12:35 -0000 Mailing-List: contact users-help@qpid.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@qpid.apache.org Delivered-To: mailing list users@qpid.apache.org Received: (qmail 86580 invoked by uid 99); 26 May 2017 15:12:35 -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; Fri, 26 May 2017 15:12:35 +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 1EE4EC059A for ; Fri, 26 May 2017 15:12:35 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -5.023 X-Spam-Level: X-Spam-Status: No, score=-5.023 tagged_above=-999 required=6.31 tests=[RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] 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 d6awo0BEJzx9 for ; Fri, 26 May 2017 15:12:33 +0000 (UTC) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 75CFA5F306 for ; Fri, 26 May 2017 15:12:33 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5D88680F98 for ; Fri, 26 May 2017 15:12:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 5D88680F98 Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx03.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=gsim@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 5D88680F98 Received: from localhost.localdomain (ovpn-116-10.phx2.redhat.com [10.3.116.10]) by smtp.corp.redhat.com (Postfix) with ESMTP id CBDCE8068A for ; Fri, 26 May 2017 15:12:26 +0000 (UTC) Subject: Re: Using QMF to know about consumers in a topic exchange To: users@qpid.apache.org References: <1495811252023-7663510.post@n2.nabble.com> From: Gordon Sim Organization: Red Hat UK Ltd, Registered in England and Wales under Company Registration No. 3798903, Directors: Michael Cunningham, Michael O'Neill, Eric Shander Message-ID: <701c87bb-2e6b-c8d7-0259-f0074d9552e5@redhat.com> Date: Fri, 26 May 2017 16:12:25 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <1495811252023-7663510.post@n2.nabble.com> Content-Type: multipart/mixed; boundary="------------BFCE601D53E878D6D80B679C" X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 26 May 2017 15:12:27 +0000 (UTC) archived-at: Fri, 26 May 2017 15:12:37 -0000 --------------BFCE601D53E878D6D80B679C Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 26/05/17 16:07, mottese wrote: > Hi, > > Suppose I have a consumer listening to amq.topic/mySubject. Can I use QMF to > tell if I have a consumer listening to that address? Right now I am trying > to use a message formatted like this: > > Message request; > request.setReplyTo(replyToAddress); > request.setProperty("x-amqp-0-10.app-id", "qmf2"); > request.setProperty("qmf.opcode", "_query_request"); > Variant::Map schemaId, content; > schemaId["_class_name"] = "queue"; > schemaId["_object_name"] = > "org.apache.qpid.broker:queue:amq.topic/mySubject"; > content["_what"] = "OBJECT"; > content["_object_id"] = schemaId; > request.setContentObject(content); > > Is there some way to modify this QMF request to get the information I'm > looking for? Thanks You need to query the bindings. The attached program will list all the bindings. You could modify the approach to filter out all but those where the exchange is "amq.topic". (You can't have the query do that filtering for you with QMF). --------------BFCE601D53E878D6D80B679C Content-Type: text/x-c++src; name="list_bindings.cpp" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="list_bindings.cpp" /* * * 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 * * http://www.apache.org/licenses/LICENSE-2.0 * * 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. * */ #include #include #include #include #include #include #include #include using namespace qpid::messaging; using namespace qpid::types; std::string getName(const std::string& id) { //object id consists of a package, class and name triple, separated by ':' //note: would probably want some checking in a real program! return id.substr(id.find_last_of(":")+1); } int main(int argc, char** argv) { Connection c(argc > 1 ? argv[1] : "localhost", "{protocol:amqp1.0}"); try { c.open(); Session session = c.createSession(); Address responses("#; {create: always, node: {x-declare: {auto-delete:True}}}"); Receiver r = session.createReceiver(responses); Sender s = session.createSender("qmf.default.direct/broker"); Message request; request.setReplyTo(responses); request.setContentType("amqp/map"); request.setProperty("x-amqp-0-10.app-id", "qmf2"); request.setProperty("qmf.opcode", "_query_request"); Variant::Map schemaId; schemaId["_class_name"] = "binding"; Variant::Map content; content["_what"] = "OBJECT"; content["_schema_id"] = schemaId; encode(content, request); s.send(request); Message response = r.fetch(); Variant::List contentIn; decode(response, contentIn); for (Variant::List::const_iterator i = contentIn.begin(); i != contentIn.end(); ++i) { Variant::Map item = i->asMap(); Variant::Map values = item["_values"].asMap(); std::string queue = getName(values["queueRef"].asMap()["_object_name"]); std::string exchange = getName(values["exchangeRef"].asMap()["_object_name"]); std::string key = values["bindingKey"]; std::cout << exchange << " " << queue << " " << key << std::endl; } session.acknowledge(); } catch(const std::exception& error) { std::cout << "ERROR: " << error.what() << std::endl; } c.close(); return 0; } --------------BFCE601D53E878D6D80B679C Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org For additional commands, e-mail: users-help@qpid.apache.org --------------BFCE601D53E878D6D80B679C--