简体   繁体   中英

Handling HTTP request-response exchange asynchronously in JAX-RS

If I write what I need as propositions:

  • A server should be able to read chunk from request body without blocking every time a client writes and flushes that chunk like Servlet 3.1's ServletInputStream#setReadListener .
  • A server should be able to write and flush chunk multiple times to response body without blocking like Servlet 3.0's HttpServletRequest#startAsync .

With JAX-RS 2.0, I couldn't meet them. For the first one, I couldn't find such support like ReadListener, and for the second one, I found AsyncResponse but its API doesn't allow writing chunk multiple times.

Is there any idea or hack to meet them with only JAX-RS API not using implementation-specific features? I tried ContainerRequestFilter , ContainerResponseFilter , ReaderInterceptor and WriterInterceptor , but they didn't help.

From their mailing list :

There is no support for non-blocking I/O in JAX-RS 2.0. It is one of the features planned for JAX-RS 2.1 in Java EE 8 .At this point, if you're interested in a portable solution, you'd need to build this on top of Servlet 3.1.

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