qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Edlira Nano <edlira.n...@gmail.com>
Subject Re: getObjects() doesn't always work
Date Wed, 20 Jan 2010 09:56:08 GMT
Thanks for your answer :)

Indeed, when I add a sleep(1), the getObjects() seems to always return a non
empty object list at first attempt.
But the problem is that according to documentation my program is supposed to
do synchronous-only operations.
Maybe I have misunderstood something, but in the console/SessionManager.h
class one can read :

"/** Create a new SessionManager
 *
 * Provide your own subclass of ConsoleListener to receive updates and
indications
 * asynchronously or leave it as its default and use only synchronous
methods. ...

 QPID_CONSOLE_EXTERN SessionManager(ConsoleListener* listener = 0,
                                       Settings settings = Settings());"


My program uses the default  listener, I thought that the C++ getObjects()
would therefore work
synchronously, as it does when following the QMF python console tutorial
synchronous style.

So my question is :
I want no updates on my objects, is there a way to use the C++ getObjects()
in a synchronous style like in the qmf python console
(which by the way works fine for me, I never get an empty list of objects
with that)?

Edlira,

2010/1/19, Jon Watte <jwatte@gmail.com>:
>
> 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 <edlira.nano@gmail.com>
> 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
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message