简体   繁体   中英

Asynchronous Pages equivalent in Java for REST Services

We are writing some REST services using Jersey. 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. 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.

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. 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.

Thanks, GG

Salut,

take a look at the Atmosphere's Framework , specifically the atmosphere-jersey module that brings asynchronous annotation to Jersey. 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. Come to our mailing list in case you need more help.

Thanks

-- Jeanfrancois (Atmosphere Creator and Leads)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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