Interesting. If I understand correctly, you are manually sending qmf2 commands to the broker. I would very much prefer to use existing qmf library instead of writing a new one. Specifically to use the library bundled with the qpidd (mrg) broker.
On Wed, Mar 21, 2012 at 12:35, Pavel Moravec <[email protected]> wrote: > .. and now also for python client (that I overlooked in email subject): > > > conn = Connection(broker) > try: > conn.open() > ssn = conn.session() > snd = ssn.sender("qmf.default.direct/broker") > reply_to = "reply-queue; {create:always, > node:{x-declare:{auto-delete:true}}}" > rcv = ssn.receiver(reply_to) > > content = { > "_object_id": {"_object_name": > "org.apache.qpid.broker:broker:amqp-broker"}, > "_method_name": "delete", > "_arguments": {"type":"queue", "name":queue_name} > } > request = Message(reply_to=reply_to, content=content) > request.properties["x-amqp-0-10.app-id"] = "qmf2" > request.properties["qmf.opcode"] = "_method_request" > snd.send(request) > > try: > response = rcv.fetch(timeout=30) > if response.properties['x-amqp-0-10.app-id'] == 'qmf2': > if response.properties['qmf.opcode'] == '_method_response': > print "Response:" > print response.content['_arguments'] > elif response.properties['qmf.opcode'] == '_exception': > raise Exception("Error: %s" % response.content['_values']) > else: raise Exception("Invalid response received, unexpected opcode: > %s" % m) > else: raise Exception("Invalid response received, not a qmfv2 method: > %s" % m) > except Empty: > print "No response received!" > except Exception, e: > print e > except ReceiverError, e: > print e > except KeyboardInterrupt: > pass > conn.close() > > > > ----- Original Message ----- > > From: "Pavel Moravec" <[email protected]> > > To: [email protected] > > Sent: Wednesday, March 21, 2012 12:33:28 PM > > Subject: Re: python QMF synchronization > > > > 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š" <[email protected]> > > > To: "users" <[email protected]> > > > 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: [email protected] > > For additional commands, e-mail: [email protected] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [email protected] > For additional commands, e-mail: [email protected] > >
