Skip to content

Updated documentation for Consumers to prefer KafkaConsumer instead #317

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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')`
Expand All @@ -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")

Expand Down
7 changes: 5 additions & 2 deletions kafka/consumer/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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,
Expand Down