On 26/05/17 18:44, mottese wrote:
Gordon Sim wrote
If you run with
QPID_LOG_ENABLE=trace+ it should give some more insight into what was
going wrong over 1.0.
I turned on trace+, but all I seem to be seeing is a whole bunch of the same
message:
[Broker] trace Dispatching to xxxxxxx#_yyyyyyy: 0
[Broker] trace Can't deliver to xxxxxxx#_yyyyyyy
I looked earlier in the log and it looks like it was able to successfully
create the response queue.
Sorry, my mistake. Not sure why the protocol was to 1.0 in that, it
looks like it was only used on 0-10. (It was a program I had lying
around from a previous request).
Attached is a revised version that works with AMQP 1.0. It uses the
Receiver::getAddress() to correctly set the reply to address. I also
updated it to use the content object methods for the message rather than
the 0-10 specific encode/decode methods.
I've tried it out myself this time before sending(!) and it works as
expected.
/*
*
* 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;
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();
Receiver r = session.createReceiver("#");
Sender s = session.createSender("qmf.default.direct/broker");
Message request;
request.setReplyTo(r.getAddress());
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;
request.setContentObject(content);
s.send(request);
Message response = r.fetch();
std::cout << "Got message" << std::endl;
Variant::List contentIn = response.getContentObject().asList();
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;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]