qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pavel Moravec <pmora...@redhat.com>
Subject Re: Jave Client with C++ Broker - Messages in Queue-size?
Date Mon, 05 Dec 2011 13:01:19 GMT
Hi,
the best way I am aware of is to use QMF to query either the queue itself (not sure if or
how possible) or to get list of all queues (though for many queues, it is quite inefficient
way).

Here is a code snippet from C++ program (rewriting to Java shall be easy, I have it only in
C++):

int main(int argc, char** argv) {
  Connection c(argc>1?argv[1]:"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"] << endl;;
    cout << map << endl << endl;
  }
  r.close();
  s.close();
  session.close();
  c.close();
  return 0;
}

Please note you have to have qpid at least 0.11 to use QMF, due to https://issues.apache.org/jira/browse/QPID-3302.

Kind regards,
Pavel Moravec


----- Original Message -----
> From: "dmounessa" <dmounessa@yahoo.com>
> To: users@qpid.apache.org
> Sent: Friday, December 2, 2011 5:42:39 PM
> Subject: Jave Client with C++ Broker -  Messages in Queue-size?
> 
> Is there a way to get Queue size from the JAVA Client?
> 
> I want to get notified when I can start sending messages on the
> queue?
> 
> Thanks
> 
> --
> View this message in context:
> http://apache-qpid-users.2158936.n2.nabble.com/Jave-Client-with-C-Broker-Messages-in-Queue-size-tp7055301p7055301.html
> Sent from the Apache Qpid users mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
> 
> 

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Mime
View raw message