@Override
public void onPartitionsRevoked(Collection<TopicPartition> partitions)
{
- partitions.forEach(tp -> seen.remove(tp.partition()));
+ partitions.forEach(tp ->
+ {
+ log.info("{} - removing partition: {}", id, tp);
+ Map<String, Integer> removed = seen.remove(tp.partition());
+ for (String key : removed.keySet())
+ {
+ log.info(
+ "{} - Seen {} messages for partition={}|key={}",
+ id,
+ removed.get(key),
+ removed,
+ key);
+ }
+ });
}
@Override
public void onPartitionsAssigned(Collection<TopicPartition> partitions)
{
- partitions.forEach(tp -> seen.put(tp.partition(), new HashMap<>()));
+ partitions.forEach(tp ->
+ {
+ log.info("{} - adding partition: {}", id, tp);
+ seen.put(tp.partition(), new HashMap<>());
+ });
}
});
{
log.info("{} - Closing the KafkaConsumer", id);
consumer.close();
-
- for (Integer partition : seen.keySet())
- {
- Map<String, Integer> byKey = seen.get(partition);
- for (String key : byKey.keySet())
- {
- log.info(
- "{} - Seen {} messages for partition={}|key={}",
- id,
- byKey.get(key),
- partition,
- key);
- }
- }
-
log.info("{} - Consumer-Thread exiting", id);
}
}