import kafka.producer.Partitioner;
import kafka.utils.VerifiableProperties;
public class MyPartitioner implements Partitioner {
public MyPartitioner(VerifiableProperties props) {}
public int partition(Object key, int partitionCount) {
return Integer.valueOf((String) key) % partitionCount;
}
}
Properties props =newProperties();
props.put("partitioner.class","com.kafka.MyPartitioner");
网友评论