On 09/19/2011 11:24 AM, Petr Svoboda wrote:
Hi!I have troubles with sending persistent messages to persistent queue. When I set small sender capacity, after it is once filled, sender will never recover. If I set sender capacity to 10, sender is able to send only 10 messages before filling capacity (sometimes little bit more). When I use timeout, InsufficientCapacity exception is raised and than it is not possible to send messages anymore. When I don't use timeout, sender just waits forever once capacity is filled. With growing capacity, it is usually possible to send more messages (thousands) before sender gets stuck. With capacity set to 100 or more, I'm not able to reproduce it. I use this code (python): ... snd = ssn.sender(address, durable=True) snd.capacity = 10 while True: msg = Message(subject="test", properties={"spout-id": "%7d" % count}, content="X"*30) try: snd.send(msg, sync=False, timeout=0.5) except exceptions.InsufficientCapacity: time.sleep(1) If I use sync sending, it works. If the queue or messages are not durable, it works too. All sent messages are received from queue and acked - the sender capacity is occupied by messages already delivered to someone else. I'm using qpid-cpp broker 0.10 and python bindings 0.10. It's built form RHEL 6.0 sources. It behaved the same, when I used python bindings generated by swig. I'm not able to test it with 0.12, because it is crashing with persistent message store on my system. Is it bug or I just misuse the api?
Capacity is freed up as messages are confirmed by the broker. When using synchronous sends, this happens before the call returns which is why there is not a problem. However, with asynchronous sends, the client never asks the broker to respond and so messages are not cleared out simply by waiting.
My suggestion would be to replace the time.sleep(1) with a call to ssn.sync(). That will block until the server has confirmed all outstanding messages, which will mean that capacity has been freed up.
--------------------------------------------------------------------- Apache Qpid - AMQP Messaging Implementation Project: http://qpid.apache.org Use/Interact: mailto:[email protected]
