qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Moravec <pmora...@redhat.com>
Subject Re: Check Exchange present or not in Qpid C++ broker ?
Date Mon, 24 Nov 2014 12:12:30 GMT
I recommend using QMF for that. You can start with my program getting queue details:


#include <qpid/messaging/Connection.h>
#include <qpid/messaging/Session.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Address.h>

#include <qpid/types/Variant.h>

#include <iostream>
#include <string>
#include <cstdlib>

using namespace qpid::types;
using namespace qpid::messaging;

int main(int argc, char** argv)
{
    if (argc < 2) {
      std::cerr << "Missing queue name to print." << std::endl;
      return 1;
    }
    std::string queue_string = "org.apache.qpid.broker:queue:";
    queue_string += argv[1];
    Connection connection(argc>2?argv[2]:"localhost:5672");
    connection.open();
    Session session = connection.createSession();

    Address responseAddress("#reply;{create:always, delete:always, node:{type:queue}}");
    Receiver responseReceiver = session.createReceiver(responseAddress);
    responseReceiver.setCapacity(100);

    Sender requestSender = session.createSender("qmf.default.direct/broker");

    Variant::Map objectId;
    objectId["_object_name"] = queue_string;

    Variant::Map request;
    request["_what"] = "OBJECT";
    request["_object_id"] = objectId;

    Message requestMessage;
    encode(request, requestMessage);
    requestMessage.setReplyTo(responseAddress);
    requestMessage.setProperty("x-amqp-0-10.app-id",  "qmf2");
    requestMessage.setProperty("qmf.opcode", "_query_request");
    requestSender.send(requestMessage);

    Message response;
    usleep(100);
    while (responseReceiver.fetch(response, Duration::IMMEDIATE ))
    {
        Variant::List responseContent;
        decode(response, responseContent);

        for (Variant::List::iterator i = responseContent.begin(); i != responseContent.end();
++i)
        {
            Variant::Map values = (i->asMap()["_values"]).asMap();
	    std::cout << values << std::endl;
        }
    }

    session.acknowledge();
    connection.close();
    return 1;
}



Kind regards,
Pavel


----- Original Message -----
> From: "RajendraNPTL" <prrswr@gmail.com>
> To: users@qpid.apache.org
> Sent: Monday, 24 November, 2014 12:02:35 PM
> Subject: Check Exchange present or not in Qpid C++ broker ?
> 
> Hello Everyone,I am using Apache Qpid C++ broker. i want to check the
> Exchange/Queue is already exist or not in the broker through a simple C++
> program. Can anybody have idea regarding this ? Thank you
> 
> 
> 
> 
> -----
> Time and tide waits for NONE ..!!
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Check-Exchange-present-or-not-in-Qpid-C-broker-tp7616713.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Mime
View raw message