繁体   English   中英

从 Apache Beam (GCP Dataflow) 写入 ConfluentCloud

[英]Write to ConfluentCloud from Apache Beam (GCP Dataflow)

我正在尝试使用以下方法从 Dataflow (Apache Beam) 写入 Confluent Cloud/Kafka:

kafkaKnowledgeGraphKVRecords.apply("Write to Kafka", KafkaIO.<String, String>write()
                                .withBootstrapServers("<mybootstrapserver>.confluent.cloud:9092")
                                .withTopic("testtopic").withKeySerializer(StringSerializer.class)
                                .withProducerConfigUpdates(props).withValueSerializer(StringSerializer.class));

其中Map<String, Object> props = new HashMap<>(); (即暂时为空)

在日志中,我得到: send failed : 'Topic testtopic not present in metadata after 60000 ms.'

该主题确实存在于该集群上 - 所以我的猜测是登录存在问题,这是有道理的,因为我找不到传递 APIKey 的方法。

我确实尝试了各种组合来将我从 Confluent Cloud 拥有的 APIKey/Secret 传递给上面的props进行身份验证,但我找不到工作设置。

找到了解决方案,感谢问题下方@RobinMoffatt 评论中的指示

这是我现在的设置:

Map<String, Object> props = new HashMap<>()

props.put("ssl.endpoint.identification.algorithm", "https");
props.put("sasl.mechanism", "PLAIN");
props.put("request.timeout.ms", 20000);
props.put("retry.backoff.ms", 500);
props.put("sasl.jaas.config","org.apache.kafka.common.security.plain.PlainLoginModule required username=\"<APIKEY>\" password=\"<SECRET>\";");
props.put("security.protocol", "SASL_SSL");

kafkaKnowledgeGraphKVRecords.apply("Write to Kafka-TESTTOPIC", KafkaIO.<String, String>write()
    .withBootstrapServers("<CLUSTER>.confluent.cloud:9092")
    .withTopic("test").withKeySerializer(StringSerializer.class)
    .withProducerConfigUpdates(props).withValueSerializer(StringSerializer.class));

我错的关键是sasl.jaas.config (注意最后的; !)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM