diff options
author | Mahendra M <mahendra.m@gmail.com> | 2013-06-26 13:54:12 +0530 |
---|---|---|
committer | Mahendra M <mahendra.m@gmail.com> | 2013-06-26 13:54:12 +0530 |
commit | 0c0e163894c6fe4fdc4d3fe1beec2414d367bfbd (patch) | |
tree | 2fc47309508a2a5fdc82f7a09c6bbbfbff5cb2c8 | |
parent | efb1dabd1343de3be3371720244d9c1300951bfd (diff) | |
download | kafka-python-0c0e163894c6fe4fdc4d3fe1beec2414d367bfbd.tar.gz |
Update README with examples
-rw-r--r-- | README.md | 11 | ||||
-rw-r--r-- | kafka/producer.py | 2 |
2 files changed, 12 insertions, 1 deletions
@@ -54,6 +54,17 @@ if response: print(response[0].error) print(response[0].offset) +# To send messages in batch. You can use any of the available +# producers for doing this. The following producer will collect +# messages in batch and send them to Kafka after 20 messages are +# collected or every 60 seconds +# Notes: +# * If the producer dies before the messages are sent, there will be losses +# * Call producer.stop() to send the messages and cleanup +producer = SimpleProducer(kafka, "my-topic", batch_send=True, + batch_send_every_n=20, + batch_send_every_t=60) + # To consume messages consumer = SimpleConsumer(kafka, "my-group", "my-topic") for message in consumer: diff --git a/kafka/producer.py b/kafka/producer.py index da7cd96..be80c62 100644 --- a/kafka/producer.py +++ b/kafka/producer.py @@ -152,7 +152,7 @@ class Producer(object): self.queue.put(STOP_ASYNC_PRODUCER) self.proc.join(timeout) - if self.proc.is_alive() + if self.proc.is_alive(): self.proc.terminate() |