简体   繁体   English

使异步AJAX调用同步

[英]Making Async AJAX calls Synchronous

Environment: Ext-JS Frontend UI -> AJAX Calls -> Spring MVC Server/Java -> Apache CXF to MQ -> Back-end COBOL. 环境:Ext-JS前端UI-> AJAX调用-> Spring MVC Server / Java-> Apache CXF到MQ->后端COBOL。

Based on the above environment we can not handle asynchronous AJAX calls being sent due to a limitation with the backend COBOL server. 基于上述环境,由于后端COBOL服务器的限制,我们无法处理正在发送的异步AJAX调用。 Normally we daisy chain our ajax calls. 通常,我们以菊花链方式链接ajax调用。 However now we need an automatic refresh mechanism on some UI pages. 但是,现在我们需要一些UI页面上的自动刷新机制。 So if we happen to send a normal AJAX request from the UI at the same time as a refresh (AJAX) calls gets dispatched then we need to queue the two calls and make them effectively Synchronous. 因此,如果我们恰好在调度刷新(AJAX)调用的同时从UI发送普通的AJAX请求,则我们需要将这两个调用排入队列并使它们有效地同步。 Any solution would need to be generic though. 但是,任何解决方案都必须是通用的。

What would be the simplest way of dealing with this scenario ? 处理这种情况的最简单方法是什么? Is there a simple approach of blocking the refresh call when a request has already been dispatched? 是否已经有一种简单的方法在已经调度请求后阻止刷新调用? Or would it be best to use an ExecutorService in the Java Server layer to handle the scenario ? 还是最好在Java Server层中使用ExecutorService来处理这种情况? Or maybe futures/promises. 也许是期货/承诺。 How would I make that work ? 我将如何工作?

Hope this make sense and any suggestions on an approach would be appreciated. 希望这是有道理的,并且希望对方法提出任何建议。

您是否考虑过使用像Beanstalkd这样的排队系统,流程如下:

Ext-JS Frontend UI -> AJAX Calls -> Spring MVC Server/Java -> Beanstalkd -> Apache CXF to MQ -> Back-end COBOL.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM