Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Consumer Group not working on Kafka 0.8.1 #147

Closed
@tavoadolfoleon

Description

@tavoadolfoleon

I am using Kafka 0.8.1 with kafka-python tool and I have noticed that the consumer group has no effect on the offset. The consumer keeps reading all the messages form the beginning and when I launch two instances of the same python script the consumers get the same messages, from the beginning to

I found a portion on the code to uncoment when using 0.8.1 but that causes and error when the library is called

"...
consumer = SimpleConsumer(kafka, "my-group", topic, auto_commit=False)
File "build/bdist.linux-x86_64/egg/kafka/consumer.py", line 242, in init
File "build/bdist.linux-x86_64/egg/kafka/consumer.py", line 111, in init
NameError: global name 'OffsetFetchRequest' is not defined
..."

This is the python script:

localconsumer.py

from kafka.client import KafkaClient
from kafka.consumer import SimpleConsumer
from kafka.producer import SimpleProducer, KeyedProducer

kafka = KafkaClient("localhost:9092")
topic = "test"

To consume messages

consumer = SimpleConsumer(kafka, "my-group", topic, auto_commit=False)
for message in consumer:
print message

kafka.close()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions