在spring中遵循类似的问题。我希望能够在路由器中获得响应。并进行响应刷新,这样我就可以在不扩展 RTT 的情况下继续在服务器上工作
意思是,在春天做一些类似答案的事情:
public void doSomething(@RequestBody List<Message> messages, HttpServletResponse response) {
int code = (messages!=null && !messages.isEmpty()) ? HttpServletResponse.SC_OK
: HttpServletResponse.SC_NOT_FOUND;
if (code != HttpServletResponse.SC_OK) {
response.sendError(code, res);
return;
}
java.io.PrintWriter wr = response.getWriter();
response.setStatus(code);
wr.print(res);
wr.flush();
wr.close();
// Now it it time to do the long processing
...
}
这是我今天的 quarkus 代码:
@Path("/events")
class EventsRouter {
val logger: Logger = Logger.getLogger(EventsRouter::class.java)
@POST
@Consumes(MediaType.APPLICATION_JSON)
fun handleEvent(
@HeaderParam("User-Agent") userAgent: String?,
eventPayload: EventPayload,
): Response {
val time = LocalDateTime.now()
...
return Response.ok().build()
}
}