Pavel Moravec wrote:
Hi,
the best way I am aware of is to use QMF to query either the queue itself (not 
sure if or how possible)
To query for a specific queue one could use the ObjectId, so Pavel's snippet below recovers all queue objects so one would then iterate to find the one you want (presumably via its name property). Having found the queue you want you the extract it's ObjectId you can then periodically query using the objectId in place of the schemaId below

request["_object_id"] = objectId;

If you just need updates on a single queue that's more efficient than pulling back the list.

Depending on how frequently you need updates the broker also pushes out property and statistic updates. If you subscribe to qmf.default.topic/agent.ind.# you will get heartbeats and also data indications. However the broker only pushes updates every 10 seconds (though that period is configurable).

The queueThresholdExceeded Event might also be useful to you.

Frase.

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" <[email protected]>
To: [email protected]
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:[email protected]



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]




---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:[email protected]

Reply via email to