コード例 #1
0
 public void setWaitingToEmit(ConsumerRecords<K, V> consumerRecords) {
   List<ConsumerRecord<K, V>> waitingToEmitList = new LinkedList<>();
   for (TopicPartition tp : consumerRecords.partitions()) {
     waitingToEmitList.addAll(consumerRecords.records(tp));
   }
   waitingToEmit = waitingToEmitList.iterator();
 }
コード例 #2
0
    @Override
    public ConsumerRecords<K, V> onConsume(ConsumerRecords<K, V> records) {
      onConsumeCount++;
      if (throwExceptionOnConsume)
        throw new KafkaException("Injected exception in FilterConsumerInterceptor.onConsume.");

      // filters out topic/partitions with partition == FILTER_PARTITION
      Map<TopicPartition, List<ConsumerRecord<K, V>>> recordMap = new HashMap<>();
      for (TopicPartition tp : records.partitions()) {
        if (tp.partition() != filterPartition) recordMap.put(tp, records.records(tp));
      }
      return new ConsumerRecords<K, V>(recordMap);
    }