Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring MVC等待多个Kafka消息_Spring_Spring Mvc_Apache Kafka - Fatal编程技术网

Spring MVC等待多个Kafka消息

Spring MVC等待多个Kafka消息,spring,spring-mvc,apache-kafka,Spring,Spring Mvc,Apache Kafka,我正在开发的应用程序的设计方式是,当用户界面发出请求时,我需要等待X条卡夫卡消息到达某个主题。 大概是这样的: @GetMapping("/endpoint") public List<Users> getAll() { //publish the request to a topic userPublisher.publishUserQueryEvent(uuid, userQueryDTO); //wait for a microservice

我正在开发的应用程序的设计方式是,当用户界面发出请求时,我需要等待X条卡夫卡消息到达某个主题。 大概是这样的:

@GetMapping("/endpoint")
public List<Users> getAll() {

  //publish the request to a topic
  userPublisher.publishUserQueryEvent(uuid, userQueryDTO);
  //wait for a microservice to publish the response to another topic
  //when all responses are sentprocess them
  return processResponsesFromThatOtherTopic
}
@GetMapping(“/endpoint”)
公共列表getAll(){
//将请求发布到主题
publishUserQueryEvent(uuid,userQueryTo);
//等待微服务发布对其他主题的响应
//当所有响应都被发送时,处理它们
返回来自该其他主题的流程响应
}
我认为我可以将每个“响应”插入到数据库中,并不断检查数据库,直到看到某个参数“isLast”为真。还有其他选择吗?
另外,添加Spring WebFlux和其他rective内容不是一个选项。。。来一个简单的卡夫卡消费者怎么样?然后,您可以在
CompletableFuture
s中包装
poll()
,并等待它们全部完成(如果您觉得需要的话)