我们的后端有RESTful API,这个重要的服务需要超过1分钟才能准备好响应。
因此,大约90秒后,响应准备就绪,进程完成,但浏览器没有从服务器获得任何响应(挂起),最后失败(图像如下)。我用低数据对服务器进行了测试,并批准只有在响应超过1分钟才能准备就绪。我怎样才能解决这个问题?
这是服务:
@POST
@Path("/search")
public Response hotelSearch(@RequestBody InputValues value) {
/* sending request to several other API
retrieving data from PostgreSQL DB
creating a big DTO
*/
return Response.ok(DTO).build();
}注意:我们使用的是9.0.8,JAVA 8!导入依赖关系:
compile 'org.springframework:spring-web:4.3.6.RELEASE'
compile 'org.springframework:spring-orm:4.0.2.RELEASE'
compile 'org.springframework:spring-aspects:4.0.2.RELEASE'
compile 'org.springframework.security:spring-security-web:3.2.1.RELEASE'
compile 'org.springframework.security:spring-security-config:3.2.1.RELEASE'
compile 'org.springframework.security:spring-security-cas:3.2.1.RELEASE
compile 'org.glassfish.jersey.ext:jersey-spring3:2.6'发布于 2018-11-04 19:04:31
当所有结果都在其中时,您可以返回一个HTTP 200 OK响应,您可以立即返回一个带有Location头的HTTP 202 Accepted响应,客户机可以在其中检索结果。
然后,客户端将轮询Location头中的URL,直到使用GET方法准备好所有结果。
如果客户端在结果准备好之前检索结果,则返回一个HTTP 404 Not Found响应,可以选择使用“Retry-After`‘头”。
当客户端检索已完成的结果时,只需返回一个HTTP 200 OK响应,其中包含正文中的所有结果。
https://stackoverflow.com/questions/53142871
复制相似问题