Giuseppe
Giuseppe

Reputation: 393

Camel-Kafka component not workingfor error :"because of Brokers must be configured"

Got an error using kafka component for Apache Camel (version 2.19.1),i'm just trying to print incoming messages in topic, my pipeline is so composed:

...
context.addRoutes(new RouteBuilder() {
            public void configure() {
                from("kafka://localhost:9092?topic=test&groupId=testing")
               .to("stream:out");
  context.start();
    }
}

tried with and without "//" in endpoint.

What i got is:

Exception in thread "main" org.apache.camel.FailedToCreateRouteException: Failed to create route route1: Route(route1)[[From[kafka://localhost:9092?topic=test&groupI... because of Brokers must be configured
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:147)
at org.apache.camel.impl.DefaultCamelContext.doWarmUpRoutes(DefaultCamelContext.java:3762)
at org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:3669)
at org.apache.camel.impl.DefaultCamelContext.doStartOrResumeRoutes(DefaultCamelContext.java:3455)
at org.apache.camel.impl.DefaultCamelContext.doStartCamel(DefaultCamelContext.java:3309)
at org.apache.camel.impl.DefaultCamelContext.access$000(DefaultCamelContext.java:202)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3093)
at org.apache.camel.impl.DefaultCamelContext$2.call(DefaultCamelContext.java:3089)
at org.apache.camel.impl.DefaultCamelContext.doWithDefinedClassLoader(DefaultCamelContext.java:3112)
at org.apache.camel.impl.DefaultCamelContext.doStart(DefaultCamelContext.java:3089)
at org.apache.camel.support.ServiceSupport.start(ServiceSupport.java:61)
at org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:3026)
at org.apache.camel.MainApp.main(MainApp.java:60)
Caused by: java.lang.IllegalArgumentException: Brokers must be configured
at org.apache.camel.component.kafka.KafkaConsumer.<init>(KafkaConsumer.java:62)
at org.apache.camel.component.kafka.KafkaEndpoint.createConsumer(KafkaEndpoint.java:76)
at org.apache.camel.impl.EventDrivenConsumerRoute.addServices(EventDrivenConsumerRoute.java:69)
at org.apache.camel.impl.DefaultRoute.onStartingServices(DefaultRoute.java:103)
at org.apache.camel.impl.RouteService.doWarmUp(RouteService.java:172)
at org.apache.camel.impl.RouteService.warmUp(RouteService.java:145)
... 12 more

Process finished with exit code 1

I'm trying to figure it out, but i really don't understand what's the problem, my kafka cluster is a single broker and all is up and running (zookeeper and server), ty for help

Upvotes: 4

Views: 6853

Answers (2)

mgyongyosi
mgyongyosi

Reputation: 2667

Add brokers=localhost:9092 to the consumer uri.

Upvotes: 2

Bal&#225;zs N&#233;meth
Bal&#225;zs N&#233;meth

Reputation: 6637

Looking at this example the first part of the URL is the topic and then as parameter you can pass the brokers. So the official documentation seems to be a bit misleading to me.

from("kafka:{{consumer.topic}}?brokers={{kafka.host}}:{{kafka.port}}"
                    + "&maxPollRecords={{consumer.maxPollRecords}}"
                    + "&consumersCount={{consumer.consumersCount}}"
                    + "&seekTo={{consumer.seekTo}}"
                    + "&groupId={{consumer.group}}")
                    .routeId("FromKafka")
                .log("${body}");

But as a general advice: Camel is open source, so you can always have a look at the code and the examples there on github. You can also find those lines of the stack trace you posted there, then track down what's missing.

Upvotes: 1

Related Questions