I have a normal spring boot application with controller and service like following:
@RestController
class EventController(private val service: Service) {
@GetMapping(value = ["xxx"], provides = [APPLICATION_JSON_VALUE])
@ResponseStatus(HttpStatus.OK)
fun get() {
// call service?? is that right way?
service.get()
}
}
class Service {
fun get(): Future<String> {
xxx
}
}
However, because some of third party API I used, let's say Kafka Producer API, and the service has to return a java future (java.util.concurrent.Future
) and how should I handle this future result in my controller?