php editor Baicao brings you a Go client example of Fusion Cloud Kafka consumer with sasl.username and sasl.password. In this example, we will show how to use the Go programming language to create a consumer client capable of secure authentication with Fusion Cloud Kafka. By setting the correct sasl.username and sasl.password parameters, we can ensure that the client can successfully connect and consume messages from the Kafka topic. This example details the required libraries and code to help you quickly understand and apply this functionality. Let’s take a look!
Does anyone have a go client example of a kafka consumer using sasl.username and sasl.password?
I'm getting an error when trying to consume messages from Fusion Cloud.
Failed to connect to Kafka broker: kafka: client has run out of available brokers to talk to: EOF
confluence has its own sample repository
extract
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))
The above is the detailed content of Go client example for kafka consumer of Fusion Cloud with sasl.username and sasl.password. For more information, please follow other related articles on the PHP Chinese website!