Die Key-Statistiken werden in einer MongoDB gespeichert
[demos/kafka/training] / src / main / java / de / juplo / kafka / DriverController.java
1 package de.juplo.kafka;
2
3 import lombok.RequiredArgsConstructor;
4 import org.apache.kafka.common.TopicPartition;
5 import org.springframework.web.bind.annotation.GetMapping;
6 import org.springframework.web.bind.annotation.PostMapping;
7 import org.springframework.web.bind.annotation.RestController;
8
9 import java.util.Map;
10 import java.util.concurrent.ExecutionException;
11
12
13 @RestController
14 @RequiredArgsConstructor
15 public class DriverController
16 {
17   private final EndlessConsumer consumer;
18
19
20   @PostMapping("start")
21   public void start()
22   {
23     consumer.start();
24   }
25
26   @PostMapping("stop")
27   public void stop() throws ExecutionException, InterruptedException
28   {
29     consumer.stop();
30   }
31
32
33   @GetMapping("seen")
34   public Map<TopicPartition, PartitionStatistics> seen()
35   {
36     return consumer.getSeen();
37   }
38 }