On 11/19/2013 11:09 PM, Kerry Bonin wrote:
Hello! I was just about to look them over, as I need access to queue loads on the brokers. If you are considering deprecating them, what would be the recommended way to access QMF data from the broker in a C++ client app?
My personal recommendation is just to construct the relevant map messages yourself. It is a little messy and there isn't great documentation, but it is actually quite simple to do and in my view will be less trouble in the long run. I'm certainly willing to help out with specific questions/issues.
Attached is an example program that shows how to get the message depth for a named queue to give you an idea of what's involved.
/* * * 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) { if (argc == 1) { std::cout << "Please specify a queue name." << std::endl; return 1; } std::string queue(argv[1]); Connection c(argc > 2 ? argv[2] : "localhost"); 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 oid; oid["_object_name"] = std::string("org.apache.qpid.broker:queue:") + queue; Variant::Map content; content["_what"] = "OBJECT"; content["_object_id"] = oid; encode(content, request); s.send(request); Message response = r.fetch(); Variant::List contentIn; decode(response, contentIn); if (contentIn.size() == 1) { Variant::Map details = contentIn.front().asMap()["_values"].asMap(); std::cout << "Message depth for " << queue << " is " << details["msgDepth"] << std::endl; } else if (contentIn.size() == 0) { std::cout << "No such queue: " << queue << std::endl; } else { std::cout << "Unexpected number of entries: " << contentIn << 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