kafka-python
kafka-python copied to clipboard
set parameter sasl.jaas.config for SASL PLAIN
How to set the parameter sasl.jaas.config? The authentication is SASL and PLAIN mechanism
I was able to do it using below connection setup
from kafka import KafkaConsumer
def main():
print("Creating consumer...")
consumer = KafkaConsumer('topic_name',
auto_offset_reset='earliest', enable_auto_commit=False,
group_id='group1',
sasl_mechanism='PLAIN',
security_protocol='SASL_SSL',
sasl_plain_username='username',
sasl_plain_password='passwoed',
bootstrap_servers='server:9092'
)
for message in consumer:
print ("%s:%d:%d: key=%s value=v" % (message.topic, message.partition,
message.offset, message.key))