Working with confluent_kafka
, for some reasons i want to switch sometimes sasl_protocol
from SASL_SSL
to SASL_PLAINTEXT
.
The questions is should i code another KAFKA_CONFLUENT_SASL_AUTH
variation or i can just change sasl_protocol
and all ssl params (enable.ssl.certificate.verification
, ssl.certificate.location
, ssl.key.location
) will be ignored by confluent_kafka
?
simple code example:
from confluent_kafka import DeserializingConsumer
sasl_protocol = "SASL_SSL"
KAFKA_CONFLUENT_SASL_AUTH = {
"enable.ssl.certificate.verification": False,
"security.protocol": sasl_protocol,
"sasl.mechanism": "SCRAM-SHA-512",
"sasl.username": "insaneuser",
"sasl.password": "insanepassword",
"bootstrap.servers": "addr1:9093,addr2:9093",
"ssl.certificate.location": settings.NEW_KAFKA_SSL_CERT_LOCATION,
"ssl.key.location": settings.NEW_KAFKA_SSL_KEY_LOCATION,
}
consumer = DeserializingConsumer(
{
"group.id": "mygroup",
"reconnect.backoff.ms": 5000,
"auto.offset.reset": "earliest",
"enable.automit": True,
"session.timeout.ms": 20000,
**KAFKA_CONFLUENT_SASL_AUTH,
}
)
print(consumer.list_topics().topics)