private static TopicPartition registerConsumerToSpecificPartition(KafkaConsumer<String,String> consumer,String topic,int partition){
  TopicPartition topicPartition=new TopicPartition(topic,partition);
  List<TopicPartition> partitions=Arrays.asList(topicPartition);
  consumer.assign(partitions);
  return topicPartition;
}

private static TopicPartition registerConsumerToSpecificPartition ( KafkaConsumer < String , String > consumer , String topic , int partition ) { TopicPartition topicPartition = new TopicPartition ( topic , partition ) ; List < TopicPartition > partitions = Arrays . asList ( topicPartition ) ; consumer . assign ( partitions ) ; return topicPartition ; }
manually listens for specific topic partition . but , if you are looking for example of how to dynamically listens to partition and want to manually control offset then see manualoffsetconsumerwithrebalanceexample . java
