KAFKA 分区

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");

你可能感兴趣的:(KAFKA 分区)