[
https://issues.apache.org/jira/browse/PROTON-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13971528#comment-13971528
]
Ken Giusti commented on PROTON-564:
-----------------------------------
Nope, recv() is the only way to issue credit currently. You don't have to
call both recv() and work - especially for a simple example that blocks - just
call recv() instead of work(). recv() will block until at least one message
arrives. The work() api was added to messenger to aid in the non-blocking
model. In the 'good old days', you'd block in recv() - which would not only
wait for incoming messages, but also send any put() messages (it essentially
acts like work()).
> Messenger.work doesn't receive messages
> ---------------------------------------
>
> Key: PROTON-564
> URL: https://issues.apache.org/jira/browse/PROTON-564
> Project: Qpid Proton
> Issue Type: Bug
> Affects Versions: 0.6, 0.7
> Environment: Fedora 19, Python 2.7.5
> Reporter: Justin Ross
>
> Sink:
> {noformat}
> from proton import Messenger, Message
> msgr = Messenger()
> msgr.start()
> try:
> msgr.subscribe("amqp://~0.0.0.0:50000")
> msg = Message()
> while True:
> print "Tick; incoming={}".format(msgr.incoming)
> msgr.work()
> # msgr.recv() XXX
>
> for i in range(msgr.incoming):
> msgr.get(msg)
> print(msg)
> finally:
> msgr.stop()
> {noformat}
> Source:
> {noformat}
> from proton import Messenger, Message
> msgr = Messenger()
> msgr.start()
> try:
> msg = Message()
> msg.address = "amqp://0.0.0.0:50000/test"
> for i in range(10):
> print "Tick {}".format(i)
> msg.body = "Message {}".format(i)
> msgr.put(msg)
> msgr.send()
> finally:
> msgr.stop()
> {noformat}
> On 0.6, it blocks on one of the work calls with incoming always 0. On 0.7,
> it keeps looping through work calls with incoming always 0. The source sends
> nothing.
> Note the XXX bit in the sink. If you uncomment that. The sink consumes the
> messages.
> The python API documentation says the following:
> {noformat}
> Sends or receives any outstanding messages queued for a Messenger. This will
> block for the indicated timeout. This method may also do I/O work other than
> sending and receiving messages. For example, closing connections after
> messenger.stop() has been called.
> {noformat}
> Based on that, I expect that I should not need to call recv.
--
This message was sent by Atlassian JIRA
(v6.2#6252)