diff --git a/python/tutorial-three.md b/python/tutorial-three.md index 446d9c7..1406def 100644 --- a/python/tutorial-three.md +++ b/python/tutorial-three.md @@ -201,6 +201,7 @@ channel.basic_publish(exchange='logs', body=message) print " [x] Sent %r" % (message,) +[(full emit_log.py source)](http://github.com/rabbitmq/rabbitmq-tutorials/blob/master/python/emit_log.py) As you see, we avoided declaring exchange. If the `logs` exchange isn't created at the time this code is executed the message will be @@ -236,6 +237,7 @@ channel.basic_consume(callback, pika.asyncore_loop() +[(full receive_logs.py source)](http://github.com/rabbitmq/rabbitmq-tutorials/blob/master/python/receive_logs.py) We're done. If you want to save logs to a file, just open a console and type: diff --git a/python/tutorial-two.md b/python/tutorial-two.md index af02e47..440f1fa 100644 --- a/python/tutorial-two.md +++ b/python/tutorial-two.md @@ -148,6 +148,21 @@ Using that code we may be sure that even if you kill a worker using CTRL+C while it was processing a message, it will won't be lost. Soon after the worker dies all unacknowledged messages will be redispatched. +> #### Forgotten acknowledgment +> +> It's a pretty common mistake to miss `basic_ack`. It's an easy error, +> but the consequences are serious. Messages will be redelivered +> when your client quits (which may look like random redelivery), +> Rabbit will eat more and more memory as it won't be able to release +> any unacked messages. +> +> In order to debug this kind of mistakes you may use `rabbitmqctl` +> to print `messages_unacknowledged` field: +> +> $ sudo rabbitmqctl list_queues name messages_ready messages_unacknowledged +> Listing queues ... +> test 0 0 +> ...done. Message durability ------------------ @@ -251,6 +266,8 @@ channel.basic_publish(exchange='', routing_key='test', )) print " [x] Sent %r" % (message,) +[(full new_task.py source)](http://github.com/rabbitmq/rabbitmq-tutorials/blob/master/python/new_task.py) + And our worker: @@ -278,6 +295,7 @@ channel.basic_consume(callback, pika.asyncore_loop() +[(full worker.py source)](http://github.com/rabbitmq/rabbitmq-tutorials/blob/master/python/worker.py) Using message acknowledgments and `prefetch_count` you may set up