Java 我们请求长时间运行,UI在响应准备就绪时超时
我有一个angular应用程序和一个spring boot应用程序,有一个从UI到spring boot的请求,其中包含100-200个甚至更多的对象,对于这些对象中的每一个,在一个循环中调用另一个后端系统。 类似于Java 我们请求长时间运行,UI在响应准备就绪时超时,java,spring,multithreading,spring-boot,angular-fullstack,Java,Spring,Multithreading,Spring Boot,Angular Fullstack,我有一个angular应用程序和一个spring boot应用程序,有一个从UI到spring boot的请求,其中包含100-200个甚至更多的对象,对于这些对象中的每一个,在一个循环中调用另一个后端系统。 类似于 list.parallelStream().forEach(e->{ //code using rest template for backend. // add the responses to an array list. // i can se
list.parallelStream().forEach(e->{
//code using rest template for backend.
// add the responses to an array list.
// i can send all these objects to backend at one shot because they have some limitations and dont support it currently.
});
这需要很多时间才能完成,当所有请求完成时,UI就会超时
我尝试使用executer框架、forkjoin或parallel,但这还不够。因为浏览器会等待30-60秒
我想切换到anyc进程,在该进程中我向spring boot提交请求,从UI我应该能够在时间间隔后检查请求的状态。我尝试了延迟结果、@Async、可完成未来和StreamingResponseBody等概念。有没有办法处理这些长时间运行的请求
其中一些概念是可行的,但当输入大小增加时,它们也无法正常工作。我如何获得我的请求的状态,并使用一些进度条等来显示用户。
或者有更好的方法吗?对我来说,听起来你想流式传输数据 也许spring的反应式堆栈是您想要了解的: