简体   繁体   English

Java中等效于REST Services的异步页面

[英]Asynchronous Pages equivalent in Java for REST Services

We are writing some REST services using Jersey. 我们正在使用Jersey编写一些REST服务。 Our service make some underlying service calls which happens to be dead slow, which results in holding each thread per request for 3-4 seconds. 我们的服务进行了一些基础服务调用,而这些调用恰好非常慢,导致每个请求将每个线程保留3-4秒。 While investigating I came across Asynchronous Pages in .Net which assigns a thread to each request from thread pool and returns the thread to thread pool once I/O operation starts and gets a new thread when I/O operation is finished to do rest of the processing. 在调查期间,我遇到了.Net中的“ 异步页面”,页面将线程分配给线程池中的每个请求,并在I / O操作开始后将线程返回到线程池,并在I / O操作完成时获得新线程以完成其余操作。处理。

Is there anything similar to this exists in Jersey, where we can serve more concurrent connections instead of holding one thread for each connection until it completes. 在Jersey中是否存在与此类似的东西,在这里我们可以提供更多的并发连接,而​​不是为每个连接保留一个线程直到完成。 I don't want to POST a request, return a GUID and then keep polling for the status of the request from client, since I don't control client code. 我不想发布请求,返回GUID,然后继续轮询来自客户端的请求状态,因为我不控制客户端代码。

Thanks, GG 谢谢,GG

Salut, 敬礼

take a look at the Atmosphere's Framework , specifically the atmosphere-jersey module that brings asynchronous annotation to Jersey. 看一下Atmosphere的Framework ,特别是为J​​ersey提供异步注释的大气层球衣模块。 Take a look at one of the samples , or read this quick tutorial . 查看其中一个示例 ,或阅读此快速教程 Atmosphere's Jersey does exactly what you are looing at, without requiring you to manipulate threads or anything like that. Atmosphere的Jersey可以完全满足您的需求,而无需您操纵线程或类似的东西。 Come to our mailing list in case you need more help. 如果需要更多帮助,请访问我们的邮件列表

Thanks 谢谢

-- Jeanfrancois (Atmosphere Creator and Leads) -让弗朗西斯(Jeanfrancois)(大气创造者和潜在客户)

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

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