为解决 AWX lambda 到 Confluent Cloud 延迟问题,可以采取以下步骤:
Properties properties = new Properties();
properties.setProperty("bootstrap.servers", "");
properties.setProperty("ssl.endpoint.identification.algorithm", "https");
properties.setProperty("security.protocol", "SASL_SSL");
properties.setProperty("sasl.mechanism", "PLAIN");
properties.setProperty("sasl.username", "");
properties.setProperty("sasl.password", "");
Producer producer = new KafkaProducer<>(properties, new StringSerializer(), new StringSerializer());
for (int i = 0; i < 10; i++) {
producer.send(new ProducerRecord<>("test-topic", "key-" + i, "value-" + i));
}
producer.flush();
producer.close();
其中,
为 Confluent Cloud 的 Bootstrap 服务器地址,
和
为 Confluent Cloud 的 API 密钥和密钥。
Properties properties = new Properties();
properties.setProperty(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, "");
properties.setProperty(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, io.confluent.kafka.serializers.KafkaAvroSerializer.class.getName());
properties.setProperty(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, io.confluent.kafka.serializers.KafkaAvroSerializer.class.getName());
properties.setProperty("schema.registry.url", "");
properties.setProperty("basic.auth.credentials.source", "USER_INFO");
properties.setProperty("schema.registry.basic.auth.user.info", "<