
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 = "" ccloudAPIKey = " " ccloudAPISecret = " " schemaRegistryAPIEndpoint = " " schemaRegistryAPIKey = " " schemaRegistryAPISecret = " " ) 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))











