Skip to content

Instantly share code, notes, and snippets.

@merlin-quix
Last active January 23, 2023 08:03
Show Gist options
  • Save merlin-quix/2d3d9e5d773dfe053fd90bcf99ee1901 to your computer and use it in GitHub Desktop.
Save merlin-quix/2d3d9e5d773dfe053fd90bcf99ee1901 to your computer and use it in GitHub Desktop.
from kafka import KafkaConsumer
import json
from datetime import datetime
# Consume all the messages from the topic but do not mark them as 'read' (enable_auto_commit=False)
# so that we can re-read them as often as we like.
consumer = KafkaConsumer('nginx-log-producer-compressionv2',
group_id='test-consumer-group',
bootstrap_servers=['localhost:9092'],
value_deserializer=lambda v: json.loads(v.decode('utf-8')),
key_deserializer=lambda k: k.decode('utf-8'),
auto_offset_reset='earliest',
enable_auto_commit=False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment