The semantics of pn_messenger_recv is to block until at least one message is available. This means if you call it when there are available messages it will return immediately. Try something like this:
while (_gotcount < _getcount) { pn_messenger_recv(messenger, _getcount - _gotcount); while (pn_messenger_incoming(messenger)) { pn_messenger_get(messenger, message); // process message } } --Rafael On Mon, Jun 10, 2013 at 4:48 AM, atarutin <tarutin_and...@mail.ru> wrote: > You unserstood me correctly. > But suggested solution doesn't work. > What I did: > > pn_messenger_t* messenger = pn_messenger(); > pn_messenger_start(messenger); > > pn_messenger_subscribe(_pm.messenger, <someaddress>); > pn_messenger_set _timeout(messenger, 1000); > > int _getcount = <messages_count_to_receive>; > int _gotcount = 0; > while (_gotcount < _getcount) > { > pn_messenger_recv(messenger, _getcount - _gotcount); > //this line checks if nothing was received (maybe messages > have ended) > // Again, I get only 1 message. If I comment this line the > program enters > // an infinite loop but my queue are full of messages. > // IS IT CORRECT BEHAVIOUR? > if (_gotcount == pn_messenger_incoming(messenger)) > break; > _gotcount = pn_messenger_incoming(messenger); > } > > > > -- > View this message in context: > http://qpid.2158936.n2.nabble.com/Receiving-messages-with-PROTON-messenger-tp7593934p7593949.html > Sent from the Apache Qpid Proton mailing list archive at Nabble.com. >