Hi Sumi,
it is enough to set reply-to in the message request and have a subscriber of 
that response queue. See attached C++ example program (its purpose is to send a 
QMF query to get some queue details and requesting to get the response to the 
given queue).

So the key commands are:

//create a receiver of the response queue; I recommend having there 
"{create:always, delete:always}" part to automatically create it now and delete 
it once the receiver is closed
Receiver r = session.createReceiver(<response-queue>);

//in the request message m, set reply-to
m.setReplyTo(Address(r.getName()));

(sending the request message)

//fetch / receive the response, wait for it at most 3 seconds
m = r.fetch(3 * Duration::SECOND);


To ensure unique and exclusive access to the response queue, it makes sense to 
have the queue named with some uuid (i.e. use uuid_generate method in C++) and 
to use exclusive queue (to grant the only access to the queue only for this 
subscriber).

Kind regards,
Pavel


----- Original Message -----
> From: "Sumi" <[email protected]>
> To: [email protected]
> Sent: Thursday, April 19, 2012 7:32:14 AM
> Subject: Creation of Request and Response quese
> 
> Hi,
> I am very new to Qpid , How do i create Request and response queues
> For ex:request queue , durable , direct exchange
> "response queue" : is an temporary queue and what should be my reply
> to
> property and how to bind these two queues so that when my producer
>  send
> message to request queue , the consumer should be able to recieve
> from the
> response queue ? Please help this might be basic question  but i am
> very new
> to qpid and have been asked to create req , response queues?
> 
> --
> View this message in context:
> http://qpid.2158936.n2.nabble.com/Creation-of-Request-and-Response-quese-tp7479418p7479418.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> 
#include <qpid/messaging/Connection.h>
#include <qpid/messaging/Session.h>
#include <qpid/messaging/Sender.h>
#include <qpid/messaging/Receiver.h>
#include <qpid/messaging/Message.h>
#include <qpid/messaging/Address.h>

#include <iostream>

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

int main(int argc, char** argv) {
  if (argc < 2) {
    cerr << "Missing queue name to print." << endl;
    return 1;
  }
  string queue_name = argv[1];
  Connection c(argc>2?argv[2]:"localhost:5672");
  c.open();
  Session session = c.createSession();
  Receiver r = session.createReceiver("#qlister; {create:always, delete:always}");
  Sender s = session.createSender("qmf.default.direct/broker");

  Message m;
  m.setReplyTo(Address(r.getName()));
  m.setProperty("x-amqp-0-10.app-id", "qmf2");
  m.setProperty("qmf.opcode", "_query_request");

  Variant::Map request;
  request["_what"] = "OBJECT";
  Variant::Map schemaId;
  schemaId["_class_name"] = "queue";
  request["_schema_id"] = schemaId;

  encode(request, m);
  s.send(m);
  m = r.fetch(3 * Duration::SECOND);
  session.acknowledge(m);
  Variant::List response;
  decode(m, response);
  for(Variant::List::iterator iter = response.begin(); iter != response.end(); iter++) {
    Variant::Map map = iter->asMap();
    Variant::Map values = map["_values"].asMap();
//    cout << values["name"] << ": " << map << endl << endl; // this will print out the queue name and its complete map of all attributes and values
    if (values["name"] == queue_name) {
      cout << "queue " << values["name"] << ": qpid.max_count=" << values["arguments"].asMap()["qpid.max_count"] 
	<< ", qpid.max_size=" << values["arguments"].asMap()["qpid.max_size"] 
	<< ", msgDepth=" << values["msgDepth"] << ", byteDepth=" << values["byteDepth"] << endl;
    }
  }
  r.close();
  s.close();
  session.close();
  c.close();
  return 0;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to