EndlessProducer in RestProducer umbenannt
[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.ExceptionHandler;
5 import org.springframework.web.bind.annotation.PostMapping;
6 import org.springframework.web.bind.annotation.RestController;
7
8 import java.util.concurrent.ExecutionException;
9
10
11 @RestController
12 @RequiredArgsConstructor
13 public class DriverController
14 {
15   private final EndlessProducer producer;
16
17
18   @PostMapping("start")
19   public void start()
20   {
21     producer.start();
22   }
23
24   @PostMapping("stop")
25   public void stop() throws ExecutionException, InterruptedException
26   {
27     producer.stop();
28   }
29
30   @ExceptionHandler
31   public ErrorResponse illegalStateException(IllegalStateException e)
32   {
33     return new ErrorResponse(e.getMessage(), 400);
34   }
35 }