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 /README.md | |
| parent | efb1dabd1343de3be3371720244d9c1300951bfd (diff) | |
| download | kafka-python-0c0e163894c6fe4fdc4d3fe1beec2414d367bfbd.tar.gz | |
Update README with examples
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 11 |
1 files changed, 11 insertions, 0 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: |
