Hey Skip, the Kafka consumer is NOT thread safe. If you want to share across 
threads you will need to properly lock. Alternatively you can create a consumer 
per thread. Check out the class javadoc under the "multithreaded processing" 
for more details and suggestions.

________________________________
From: Skip Montanaro <skip.montan...@gmail.com>
Sent: Friday, December 29, 2017 11:21:52 AM
To: users@kafka.apache.org
Subject: Can I commit from a thread?

I subscribe to topics and receive input in my main thread (this
happens to be in Python):

    consumer = kafka.KafkaConsumer(...)
    for data in consumer:
        do_stuff(data)

do_stuff(...) can hand messages off to a separate thread for
processing. Is it okay to call commit() from that thread or do I need
to do the complete lock dance for that as well?

Thanks,

Skip Montanaro

Reply via email to