JavaAPI中Kafka的消费者不能正确的连接到服务器的Kafka的队列。百度、google了很多都无法解决。
这是配置信息:
props.put("zookeeper.connect", "XXXXXX:2181");
//配置Zookeeper连接超时间隔
props.put("zookeeper.connection.timeout.ms", "1000000");
//配置Zookeeper的组id(The ‘group.id’ string defines the Consumer Group this process is consuming on behalf of.)
props.put("group.id", "test-group");
props.put("zookeeper.session.timeout.ms", "4000");
props.put("zookeeper.sync.time.ms", "10000");
props.put("auto.commit.interval.ms", "1000");
props.put("rebalance.max.retries", "5");
props.put("rebalance.backoff.ms", "1200");
这是错误日志:
Exception in thread "Thread-0" kafka.common.ConsumerRebalanceFailedException: test-group_yanyongdeMacBook-Pro.local-1471403173076-d34ac5a3 can't rebalance after 5 retries
at kafka.consumer.ZookeeperConsumerConnector$ZKRebalancerListener.syncedRebalance(ZookeeperConsumerConnector.scala:660)
at kafka.consumer.ZookeeperConsumerConnector.kafka$consumer$ZookeeperConsumerConnector$$reinitializeConsumer(ZookeeperConsumerConnector.scala:967)
at kafka.consumer.ZookeeperConsumerConnector.consume(ZookeeperConsumerConnector.scala:254)
at kafka.javaapi.consumer.ZookeeperConsumerConnector.createMessageStreams(ZookeeperConsumerConnector.scala:84)
at kafka.javaapi.consumer.ZookeeperConsumerConnector.createMessageStreams(ZookeeperConsumerConnector.scala:96)
at com.yany.consumer.ConsumerTest$MyConsumer.run(ConsumerTest.java:44)
相关分类