2
我正在使用以下代碼從主題中讀取消息。閱讀後如何刪除郵件?如何在閱讀後刪除kafka消息
from kafka import KafkaConsumer
consumer = KafkaConsumer('my-topic',
group_id='my-group',
bootstrap_servers=['localhost:9092'])
for message in consumer:
# message value and key are raw bytes -- decode if necessary!
# e.g., for unicode: `message.value.decode('utf-8')`
print ("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition,
message.offset, message.key,
message.value))
這可能幫助:http://stackoverflow.com/questions/28586008/delete-message-after-consuming-it-在-卡夫卡 – Val