Spring Boot Controller处理Java的未来

时间:2018-09-12 09:19:13

标签: spring spring-boot kotlin kafka-producer-api

我有一个带有控制器和服务的普通spring boot应用程序,如下所示:

@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
  }
}

但是,由于我使用了某些第三方API,比如说Kafka Producer API,并且该服务必须返回Java Future(java.util.concurrent.Future),我应该如何在控制器中处理该Future结果?

0 个答案:

没有答案