qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Moravec <pmora...@redhat.com>
Subject Re: python QMF synchronization
Date Wed, 21 Mar 2012 11:33:28 GMT
Hi Martin,
you can set up ReplyTo address where qpid shall send its response. I.e. something like C++
code below (that invokes queue deletion and fetches response in 30seconds limit):

    Connection connection(url);
    try {
        connection.open();
        Session session = connection.createSession();
        Sender sender = session.createSender("qmf.default.direct/broker");
        Address responseQueue("#reply-queue; {create:always, node:{x-declare:{auto-delete:true}}}");
        Receiver receiver = session.createReceiver(responseQueue);

        Message message;
        Variant::Map content;
	Variant::Map OID;
	Variant::Map arguments;
	OID["_object_name"] = "org.apache.qpid.broker:broker:amqp-broker";
	arguments["type"] = "queue";
	arguments["name"] = queue_name;
	
        content["_object_id"] = OID;
        content["_method_name"] = "delete";
        content["_arguments"] = arguments;
	
        encode(content, message);
	message.setReplyTo(responseQueue);
	message.setProperty("x-amqp-0-10.app-id", "qmf2");
	message.setProperty("qmf.opcode", "_method_request");

        sender.send(message, true);
	
	Message response;
	if (receiver.fetch(response,qpid::messaging::Duration(30000)) == true)
	{
		qpid::types::Variant::Map recv_props = response.getProperties();
		if (recv_props["x-amqp-0-10.app-id"] == "qmf2")
			if (recv_props["qmf.opcode"] == "_method_response")
				std::cout << "Response: OK" << std::endl;
			else if (recv_props["qmf.opcode"] == "_exception")
				std::cerr << "Error: " << response.getContent() << std::endl;
			else
				std::cerr << "Invalid response received!" << std::endl;
		else
			std::cerr << "Invalid response not of qmf2 type received!" << std::endl;
	}
	else
		std::cout << "Timeout: No response received within 30 seconds!" << std::endl;

        connection.close();
        return 0;
    } catch(const std::exception& error) {
        std::cout << error.what() << std::endl;
        connection.close();
    }

Kind regards,
Pavel



----- Original Message -----
> From: "MartiN BeneŇ°" <martinbenesh@gmail.com>
> To: "users" <users@qpid.apache.org>
> Sent: Wednesday, March 21, 2012 12:26:59 PM
> Subject: python QMF synchronization
> 
> Hi,
> I cannot find information about qmf synchronization. Or is every call
> synchronous?
> For instance if I purge a queue: queue.purge(0)
> how can i tell it was done?
> 

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


Mime
View raw message