def index() {
def sessionTimeoutMs = 10000
def connectionTimeoutMs = 10000
def zkClient = new ZkClient("127.0.0.1:2181", sessionTimeoutMs, connectionTimeoutMs, ZKStringSerializer )
def topicName = "myTopicoo"
def numPartitions = 8
def replicationFactor = 3
def topicConfig = new Properties()
AdminUtils.createTopic(zkClient, topicName, numPartitions, replicationFactor, topicConfig)
Properties propy=new Properties()
propy.put("metadata.broker.list","localhost:9092")
propy.put("serializer.class", "kafka.serializer.StringEncoder")
//propy.put("partitioner.class", "coughka.SimplePartitioner")
propy.put("request.required.acks","1")
ProducerConfig configuration=new ProducerConfig(propy)
Producer<String,String> prod = new Producer<String,String>(configuration)
def i=0
while(i<90){
prod.send(new KeyedMessage<String, String>("myTopicoo" , "nithin"+i.toString()))
i++
}
}
}
错误:找不到匹配的构造函数: org.I0Itec.zkclient.ZkClient(java.lang.String,java.lang.Integer, java.lang.Integer,java.lang.Class)
我跟着这个: How Can we create a topic in Kafka from the IDE using API