简体   繁体   中英

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. Speficying brokername and port doesn't seem to do it. At no point am I specifying where my kafka cluster is:

       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.

What am i missing? What's the right way of specifying brokers?

Turns out it's simply

withBootstrapServers("localhost:9092")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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