Spring and Kafka integration produces error

77 views Asked by At

I am trying to use Spring and kafka in Java code but the following error is occurring every time, I run the project. Any hint for the type of error will be helpful.

2017-08-31 18:35:50.529 ERROR 8720 --- [ask-scheduler-1] o.s.integration.handler.LoggingHandler   : org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000
    at org.I0Itec.zkclient.ZkClient.connect(ZkClient.java:880)
    at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:98)
    at org.I0Itec.zkclient.ZkClient.<init>(ZkClient.java:84)
    at kafka.consumer.ZookeeperConsumerConnector.connectZk(ZookeeperConsumerConnector.scala:156)
    at kafka.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:114)
    at kafka.javaapi.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:65)
    at kafka.javaapi.consumer.ZookeeperConsumerConnector.<init>(ZookeeperConsumerConnector.scala:67)
    at kafka.consumer.Consumer$.createJavaConsumerConnector(ConsumerConnector.scala:100)
    at kafka.consumer.Consumer.createJavaConsumerConnector(ConsumerConnector.scala)
    at org.springframework.integration.kafka.support.ConsumerConnectionProvider.getConsumerConnector(ConsumerConnectionProvider.java:34)
    at org.springframework.integration.kafka.support.ConsumerConfiguration.getConsumerConnector(ConsumerConfiguration.java:264)
    at org.springframework.integration.kafka.support.ConsumerConfiguration.createMessageStreamsForTopic(ConsumerConfiguration.java:235)
    at org.springframework.integration.kafka.support.ConsumerConfiguration.createConsumerMessageStreams(ConsumerConfiguration.java:224)
    at org.springframework.integration.kafka.support.ConsumerConfiguration.receive(ConsumerConfiguration.java:96)
    at org.springframework.integration.kafka.support.KafkaConsumerContext.receive(KafkaConsumerContext.java:73)
    at org.springframework.integration.kafka.inbound.KafkaHighLevelConsumerMessageSource.receive(KafkaHighLevelConsumerMessageSource.java:41)
    at org.springframework.integration.endpoint.SourcePollingChannelAdapter.receiveMessage(SourcePollingChannelAdapter.java:144)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.doPoll(AbstractPollingEndpoint.java:192)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint.access$000(AbstractPollingEndpoint.java:55)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:149)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$1.call(AbstractPollingEndpoint.java:146)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller$1.run(AbstractPollingEndpoint.java:298)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor$1.run(ErrorHandlingTaskExecutor.java:52)
    at org.springframework.core.task.SyncTaskExecutor.execute(SyncTaskExecutor.java:50)
    at org.springframework.integration.util.ErrorHandlingTaskExecutor.execute(ErrorHandlingTaskExecutor.java:49)
    at org.springframework.integration.endpoint.AbstractPollingEndpoint$Poller.run(AbstractPollingEndpoint.java:292)
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
    at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:81)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
1

There are 1 answers

1
Gary Russell On BEST ANSWER

2017-08-31 18:35:50.529 ERROR 8720 --- [ask-scheduler-1] o.s.integration.handler.LoggingHandler : org.I0Itec.zkclient.exception.ZkTimeoutException: Unable to connect to zookeeper server within timeout: 6000

Looks like zookeeper's not running.

See the quickstart - you need to start the zookeeper and kafka servers.