Created
February 15, 2023 22:28
-
-
Save kuznetsov-m/18346a216bd7a1cf517e6b79ee53a111 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kafka import KafkaConsumer | |
host = '' | |
topic = '' | |
user = '' | |
password= '' | |
sasl_mechanism = 'SCRAM-SHA-512' | |
security_protocol = 'SASL_SSL' | |
consumer = KafkaConsumer( | |
topic, | |
sasl_mechanism = sasl_mechanism, | |
security_protocol = security_protocol, | |
ssl_cafile='CA.pem', | |
sasl_plain_username = user, | |
sasl_plain_password = password, | |
bootstrap_servers=[host], | |
ssl_check_hostname=False | |
) | |
for message in consumer: | |
value = message.value.decode("utf-8").replace("\\\\", "\\") | |
print(f'{message.topic}:{message.partition}:{message.offset}: \ | |
key={message.key} value={value}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment