简体   繁体   English

如何在 Apache Beam 中使用 KafkaIO 指定 kafka 代理

[英]how to specify kafka brokers with KafkaIO in Apache Beam

I'm trying to setup a KafkaIO pipeline but i can't figure out how to specify brokers.我正在尝试设置 KafkaIO 管道,但我不知道如何指定代理。 Speficying brokername and port doesn't seem to do it.指定经纪人名称和端口似乎并没有这样做。 At no point am I specifying where my kafka cluster is:我从来没有指定我的 kafka 集群在哪里:

       pipeline
            .apply(KafkaIO.<Long, String>read()
                    .withBootstrapServers("broker.id__1:9092")
                    .withTopic("pageviews")

which gives me the error:这给了我错误:

        Exception in thread "main" org.apache.beam.sdk.Pipeline$PipelineExecutionException: org.apache.kafka.common.KafkaException: Failed to construct kafka consumer
        at org.apache.beam.sdk.Pipeline.run(Pipeline.java:323)
...
    Caused by: org.apache.kafka.common.config.ConfigException: No resolvable bootstrap urls given in bootstrap.servers

My Kafka cluster is running locally and the broker id is correct.我的 Kafka 集群在本地运行,并且代理 ID 正确。

What am i missing?我错过了什么? What's the right way of specifying brokers?指定经纪人的正确方法是什么?

Turns out it's simply原来这很简单

withBootstrapServers("localhost:9092")

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

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