0

I'm having problem using the last answer of this question in my Java code. Kafka: Get broker host from ZooKeeper

Specifically, it fails finding the last argument on this line:

ZkClient client = new ZkClient("localhost:2181", 10000, kafka.utils.ZKStringSerializer);

I'm using Maven and these are the dependencies in the pom.xml if it matters.

<dependencies>
        <dependency>
                <groupId>org.apache.kafka</groupId>
                <artifactId>kafka_2.11</artifactId>
                <version>0.8.2.2</version>
        </dependency>
        <dependency>
                <groupId>com.101tec</groupId>
                <artifactId>zkclient</artifactId>
                <version>0.7</version>
        </dependency>
</dependencies>
2
  • Did you get a compile time issue? Commented Dec 4, 2015 at 6:07
  • @localhost999 Yes, it's compile time issue. Commented Dec 4, 2015 at 14:24

1 Answer 1

2

You have to use like this

ZkClient client = new ZkClient("localhost:2181", Integer.MAX_VALUE,10000, kafka.utils.ZKStringSerializer$.MODULE$);

kafka.utils.ZKStringSerializer is a scala object. To use scala object in java you have to use like above.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! It works! I would have never figured that out since I'm still a newbie in Scala.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.