Hello guys, Issue created: https://issues.apache.org/jira/browse/PROTON-1201 Regards,Adel
> Date: Tue, 17 May 2016 12:00:07 +0200 > Subject: Re: Proton C++ question > From: rabih.prom...@gmail.com > To: users@qpid.apache.org > > Thank you Gordon for your reply. > > I tried to add the link.close() in addition to connection.close() but the > problem remains. > > The workaround with the credit window works. > > May be I should create a Jira issue for the bug. > > Thanks, > Rabih > > On Tue, May 17, 2016 at 10:59 AM, Gordon Sim <g...@redhat.com> wrote: > > > On 10/05/16 11:38, Rabih M wrote: > > > >> Hello, > >> > >> > >> > >> I have an issue while using proton C++ binding 0.12.0. In my use case, I > >> need to get one and only one message from a distant queue. > >> > >> But I am not able to do it with proton. I read that in the constructor of > >> handler I could specify that using prefetch parameter, but it is not > >> working. > >> > > > > I'm not an expert on the c++ binding, but the prefetch is a window that is > > automatically moved. So even if the window is only 1 message wide, once > > that message is handled the library will automatically issue credit to move > > the window forward. > > > > > > That said, it is reasonable to expect that closing the connection as you > > do on receiving the first message would prevent credit being reissued. Have > > you tried closing the link as well? Does that make a difference? If not I'd > > suggest this is a bug (the library should not issue extra credit on a link > > that the application has requested be closed). > > > > As a workaround, you should be able to disable the credit window be > > setting it to 0, then use the receiver::flow() method to add a single > > message credit. > > > > Btw, I believe this has changed on the master (and therefore will be > > different in the next release). It seems the prefetch is now called > > credit_window, and is set through the link_options when creating the > > receiver. Also the flow() method is now add_credit. > > > > Again, I repeat I am not an expert on the c++ binding, so apologies if any > > of the above is incorrect. Hopefully one of the experts will then step in > > and correct me :-) > > > > Example: > >> > >> Let’s consider I have a queue on the network that contains 2 messages. > >> > >> Here is my handler’s implementation: > >> > >> class SimpleReceiver : public proton::handler { > >> > >> private: > >> > >> proton::url url; > >> > >> > >> > >> public: > >> > >> SimpleReceiver(const proton::url& u) : *handler(1)*, url(u) {} > >> > >> > >> > >> void on_start(proton::event &e) { > >> > >> proton::connection conn = e.container().connect(url); > >> > >> conn.open_receiver(url.path()); > >> > >> } > >> > >> > >> > >> void on_message(proton::event &e) { > >> > >> std::cout << e.message().body() << std::endl; > >> > >> e.connection().close(); > >> > >> } > >> > >> }; > >> > >> > >> > >> When I run this code the queue is emptied and the client took the 2 > >> messages from the queue. > >> > >> > >> > >> Could you help me understand why I am getting this behavior? > >> > >> > >> > >> Thank you, > >> > >> Rabih > >> > >> > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@qpid.apache.org > > For additional commands, e-mail: users-h...@qpid.apache.org > > > >