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 有自己的示例存储库
https://github.com /confluenceinc/confluence-kafka-go/blob/master/examples/confluence_cloud_example/confluence_cloud_example.go
摘录
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))
登录后复制
以上就是具有 sasl.username 和 sasl.password 的融合云的 kafka 消费者的 go 客户端示例的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2355591.html