Here's just guessing from reading the code you posted:

That looks like a spin loop to me. If the objects arrive asynchronously, you
won't know how many iterations it will take, because it is timing dependent.
If you add sleep(1) right before you call getObjects() in the loop, how does
it behave in that case?

If the documentation contradicts this guess, then I'd vote for trusting the
documentation, though :-)

Sincerely,

jw



--
Americans might object: there is no way we would sacrifice our living
standards for the benefit of people in the rest of the world. Nevertheless,
whether we get there willingly or not, we shall soon have lower consumption
rates, because our present rates are unsustainable.



On Tue, Jan 19, 2010 at 8:46 AM, Edlira Nano <[email protected]> wrote:

> Hi everyone,
>
> I am using C++ Broker along with C++ Clients built from trunk on RedHat
> CentOS.
>
> First I noticed that the ./console program from the qmf-console example
> wasn't
> getting any object from the broker (while ping and queuestats work fine)
>
> Then, I did a little program that uses getObjects() from the console
> SessionManager
> and noticed that it is not getting any queue object every time I call it.
>
> Here is what I'm doing :
> - A broker is running on localhost:5672
> - A queue named "message_queue" has been created on it (using
> declare_queues from the direct example)
> - I wrote the following program which uses getObjects() to get a list
> of queue objects from the broker,
>  looks for the queue named "message_queue" in the list and prints
> some information about it. The program
> is not even implementing its own ConsoleListener like ./console, but
> it'using the default one  :
>
> #include "qpid/console/SessionManager.h"
> using namespace std;
> using namespace qpid::console;
>
> int main_int(int /*argc*/, char** /*argv*/)
> {
>  qpid::client::ConnectionSettings connSettings;
>
>  SessionManager sm;
>  Broker* broker = sm.addBroker(connSettings);
>
>  Object::Vector list;
>  int counter = 0;
>
>  do {
>    counter++;
>    cout << "Getting queue objects list, attempt no " << counter << endl;
>    sm.getObjects(list, "queue");
>    cout << "   returned " << list.size() << " elements" << endl;
>  }
>  while(list.empty());
>
>  for (Object::Vector::iterator i = list.begin(); i != list.end();
>       i++) {
>    cout << "queue: " << *i << endl;
>    if ((i->attrString("name")) == "message_queue") {
>      cout << "nbMessages: " << i->attrUint64("msgDepth") << endl;
>      cout << "size: " << i->attrUint64("byteDepth") << endl;
>      break;
>    }
>  }
>  sm.delBroker(broker);
>  return 0;
> }
>
> int main(int argc, char** argv)
> {
>    try {
>        return main_int(argc, argv);
>    } catch(std::exception& e) {
>        cout << "Top Level Exception: " << e.what() << endl;
>    }
> }
>
> Here are the last lines of the output I get from the above program :
>
> Getting queue objects list, attempt no 705
>   returned 0 elements
> Getting queue objects list, attempt no 706
>   returned 4 elements
> queue: org.apache.qpid.broker:queue[0-217-1-0-3]
> 0-0-1-0-1152921504606846979:message_queue
> nbMessages: 11
> size: 108
>
> So, i have to do getObjects() 706 times to get a non empty list of
> queue objects.
> The number of attempts varies from one call to another, the max I get
> is around 1200 times, the minimum
> 120 times.
>
> Does anyone have any idea about this?
>
> Thanks,
> Edlira
>

Reply via email to