Merge branch 'endless-stream-consumer' into rebalance-listener
[demos/kafka/training] / src / main / java / de / juplo / kafka / DriverController.java
1 package de.juplo.kafka;
2
3 import lombok.RequiredArgsConstructor;
4 import org.springframework.web.bind.annotation.GetMapping;
5 import org.springframework.web.bind.annotation.PostMapping;
6 import org.springframework.web.bind.annotation.RestController;
7
8 import java.util.Map;
9 import java.util.concurrent.ExecutionException;
10
11
12 @RestController
13 @RequiredArgsConstructor
14 public class DriverController
15 {
16   private final EndlessConsumer consumer;
17
18
19   @PostMapping("start")
20   public void start()
21   {
22     consumer.start();
23   }
24
25   @PostMapping("stop")
26   public void stop() throws ExecutionException, InterruptedException
27   {
28     consumer.stop();
29   }
30
31
32   @GetMapping("seen")
33   public Map<Integer, Map<String, Integer>> seen()
34   {
35     return consumer.getSeen();
36   }
37 }