![](/img/trans.png)
[英]Apache Beam With GCP Dataflow throws INVALID_ARGUMENT
[英]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.