Here is an example of querying a broker using C++ to implement the QMF protocol.
This was posted by Gordon Sim some years ago. ----- Original Message ----- > From: "Paul A. Flores" <paul.a.flo...@saic.com> > To: users@qpid.apache.org > Sent: Tuesday, October 25, 2016 10:22:03 AM > Subject: How, from within a C++ application, is it possible to 'examine' and > 'manage' a broker? > > Hi, > > > As the subject line states: "How, from within a C++ application, is it > possible to 'examine' and 'manage' a broker?" > > > The requirements are rather straightforward we would like to be able to > answer the following questions.: > > > * How many 'clients' (senders and receivers) are 'connected' to a 'broker'? > > > > * How many receivers/subscribers are attached/subscribed to a queue/ topic? > > > * How many senders/publishers are writing/publishing to a queue/topic? > > > >Is it only one or can their be multiple senders/publishers to a > >queue/topic? > > > *When was the last time a message was retrieved from a queue/topic? > > > *How to 'empty/clear' messages from a queue/topic from within a C++ > application? > > > As stated earlier we are replacing CORBA messaging with QPID. To that regard > the client has a considerable amount of message channel 'management' that is > 'baked' into their 'framework'. While the goal is to shift away from the > CORBA paradigm we are faced with task of identifying. developing and > implementing 'like' functionality and this is one area we would like some > 'sage' advice and guidance. > > > Thanks > > > Paul > > > ________________________________ > > This communication (including any attachments) may contain information that > is proprietary, confidential or exempt from disclosure. If you are not the > intended recipient, please note that further dissemination, distribution, > use or copying of this communication is strictly prohibited. Anyone who > received this message in error should notify the sender immediately by > telephone or by return email and delete it from his or her computer. >
/* * * 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 <qpid/messaging/Address.h> #include <qpid/messaging/Connection.h> #include <qpid/messaging/Message.h> #include <qpid/messaging/Receiver.h> #include <qpid/messaging/Sender.h> #include <qpid/messaging/Session.h> #include <qpid/types/Variant.h> #include <iostream> using namespace qpid::messaging; using namespace qpid::types; using std::string; int main(int argc, char** argv) { Connection c(argc > 1 ? argv[1] : "localhost", "{protocol:amqp1.0}"); try { c.open(); Session session = c.createSession(); Receiver r = session.createReceiver("#"); Sender s = session.createSender("qmf.default.direct/broker"); Message request; request.setReplyTo(r.getAddress()); request.setProperty("x-amqp-0-10.app-id", "qmf2"); request.setProperty("qmf.opcode", "_query_request"); Variant::Map schemaId; schemaId["_class_name"] = "broker"; Variant::Map content; content["_what"] = "OBJECT"; content["_schema_id"] = schemaId; request.setContentObject(content); s.send(request); Message response = r.fetch(); Variant::List contentIn = response.getContentObject().asList(); for (Variant::List::const_iterator i = contentIn.begin(); i != contentIn.end(); ++i) { Variant::Map item = i->asMap(); std::cout << item["_values"] << std::endl; } session.acknowledge(); } catch(const std::exception& error) { std::cout << "ERROR: " << error.what() << std::endl; } c.close(); return 0; }
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org For additional commands, e-mail: users-h...@qpid.apache.org