简体   繁体   English

从 Apache Beam (GCP Dataflow) 写入 ConfluentCloud

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

I am trying to write to write to Confluent Cloud/Kafka from Dataflow (Apache Beam), using the following:我正在尝试使用以下方法从 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));

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

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

The topic does exist on this cluster - so my guess is that there is an issue with login, which makes sense as I couldn't find a way to pass the APIKey.该主题确实存在于该集群上 - 所以我的猜测是登录存在问题,这是有道理的,因为我找不到传递 APIKey 的方法。

I did try various combinations to pass the APIKey/Secret I have from Confluent Cloud to auth with the props above but I couldn't find a working setup.我确实尝试了各种组合来将我从 Confluent Cloud 拥有的 APIKey/Secret 传递给上面的props进行身份验证,但我找不到工作设置。

Found a solution, thanks to the pointers in the comments of @RobinMoffatt below the question找到了解决方案,感谢问题下方@RobinMoffatt 评论中的指示

Here's the setup I have now:这是我现在的设置:

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));

The key line I had wrong is the sasl.jaas.config (note the ; at the end!)我错的关键是sasl.jaas.config (注意最后的; !)

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

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