while (true)
{
- ConsumerRecords<String, String> records =
- consumer.poll(Duration.ofSeconds(1));
-
- // Do something with the data...
- log.info("{} - Received {} messages", id, records.count());
- for (ConsumerRecord<String, String> record : records)
- {
- consumed++;
- log.info(
- "{} - {}: {}/{} - {}={}",
- id,
- record.offset(),
- record.topic(),
- record.partition(),
- record.key(),
- record.value()
- );
-
- Integer partition = record.partition();
- String key = record.key();
-
- if (!seen.containsKey(partition))
- seen.put(partition, new HashMap<>());
-
- Map<String, Integer> byKey = seen.get(partition);
-
- if (!byKey.containsKey(key))
- byKey.put(key, 0);
-
- int seenByKey = byKey.get(key);
- seenByKey++;
- byKey.put(key, seenByKey);
- }
+ // TODO: Nachrichten empfangen und zählen
}
}
catch(WakeupException e)