
php小编百草为您带来了一个关于具有sasl.username和sasl.password的融合云Kafka消费者的Go客户端示例。在这个示例中,我们将展示如何使用Go编程语言创建一个能够与融合云Kafka进行安全认证的消费者客户端。通过设置正确的sasl.username和sasl.password参数,我们可以确保客户端能够成功连接和消费Kafka主题中的消息。这个示例将详细介绍所需的库和代码,帮助您快速理解和应用这一功能。让我们一起来看看吧!
有人有一个使用 sasl.username 和 sasl.password 的 kafka 消费者的 go 客户端示例吗?
我在尝试使用来自融合云的消息时遇到错误。
Failed to connect to Kafka broker: kafka: client has run out of available brokers to talk to: EOF
confluence 有自己的示例存储库
摘录
bootstrapServers = "<BOOTSTRAP_SERVERS>"
ccloudAPIKey = "<CCLOUD_API_KEY>"
ccloudAPISecret = "<CCLOUD_API_SECRET>"
schemaRegistryAPIEndpoint = "<CCLOUD_SR_ENDPOINT>"
schemaRegistryAPIKey = "<CCLOUD_SR_API_KEY>"
schemaRegistryAPISecret = "<CCLOUD_SR_API_SECRET>"
)
func main() {
topic := "go-test-topic"
createTopic(topic)
// Produce a new record to the topic...
producer, err := kafka.NewProducer(&kafka.ConfigMap{
"bootstrap.servers": bootstrapServers,
"sasl.mechanisms": "PLAIN",
"security.protocol": "SASL_SSL",
"sasl.username": ccloudAPIKey,
"sasl.password": ccloudAPISecret})
if err != nil {
panic(fmt.Sprintf("Failed to create producer: %s", err))
}
client, err := schemaregistry.NewClient(schemaregistry.NewConfigWithAuthentication(
schemaRegistryAPIEndpoint,
schemaRegistryAPIKey,
schemaRegistryAPISecret))以上就是具有 sasl.username 和 sasl.password 的融合云的 kafka 消费者的 go 客户端示例的详细内容,更多请关注php中文网其它相关文章!
全网最新最细最实用WPS零基础入门到精通全套教程!带你真正掌握WPS办公! 内含Excel基础操作、函数设计、数据透视表等
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号