最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - confluent_kafka ignore ssl params in config - Stack Overflow

programmeradmin0浏览0评论

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)
发布评论

评论列表(0)

  1. 暂无评论