diff options
author | Dana Powers <dana.powers@gmail.com> | 2015-02-10 16:25:04 -0800 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2015-02-10 16:25:04 -0800 |
commit | 60a73788ee9036a79078193dfab892c6e6ef8f9b (patch) | |
tree | 0e03d46ad42734bb794c5e2397428b7daeace6e5 | |
parent | e94fd220923e3b24f27636cc8bb4f39ab89dcb73 (diff) | |
parent | aa19d71f9804f431199f4f68087ad4a53b0cbab9 (diff) | |
download | kafka-python-60a73788ee9036a79078193dfab892c6e6ef8f9b.tar.gz |
Merge pull request #317 from sontek/update_consumer_docs
Updated documentation for Consumers to prefer KafkaConsumer instead
-rw-r--r-- | docs/usage.rst | 8 | ||||
-rw-r--r-- | kafka/consumer/kafka.py | 7 |
2 files changed, 10 insertions, 5 deletions
diff --git a/docs/usage.rst b/docs/usage.rst index 5f3fcea..141cf93 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -6,7 +6,7 @@ High level .. code:: python - from kafka import KafkaClient, SimpleProducer, SimpleConsumer + from kafka import SimpleProducer, KafkaClient, KafkaConsumer # To send messages synchronously kafka = KafkaClient("localhost:9092") @@ -52,7 +52,8 @@ High level batch_send_every_t=60) # To consume messages - consumer = SimpleConsumer(kafka, "my-group", "my-topic") + consumer = KafkaConsumer("my-topic", group_id="my_group", + metadata_broker_list=["localhost:9092"]) for message in consumer: # message is raw byte string -- decode if necessary! # e.g., for unicode: `message.decode('utf-8')` @@ -66,7 +67,8 @@ Keyed messages .. code:: python - from kafka import KafkaClient, KeyedProducer, HashedPartitioner, RoundRobinPartitioner + from kafka import (KafkaClient, KeyedProducer, HashedPartitioner, + RoundRobinPartitioner) kafka = KafkaClient("localhost:9092") diff --git a/kafka/consumer/kafka.py b/kafka/consumer/kafka.py index ae0f0b9..cd3cc4a 100644 --- a/kafka/consumer/kafka.py +++ b/kafka/consumer/kafka.py @@ -57,7 +57,8 @@ class KafkaConsumer(object): .. code:: python # A very basic 'tail' consumer, with no stored offset management - kafka = KafkaConsumer('topic1') + kafka = KafkaConsumer('topic1', + metadata_broker_list=['localhost:9092']) for m in kafka: print m @@ -73,8 +74,10 @@ class KafkaConsumer(object): .. code:: python - # more advanced consumer -- multiple topics w/ auto commit offset management + # more advanced consumer -- multiple topics w/ auto commit offset + # management kafka = KafkaConsumer('topic1', 'topic2', + metadata_broker_list=['localhost:9092'], group_id='my_consumer_group', auto_commit_enable=True, auto_commit_interval_ms=30 * 1000, |