Asynchronous HTTP Request Processing in RESTEasy
The Resteasy asychronous HTTP support is implemented via two classes. The @Suspend annotation and the AsynchronousResponse interface. public @interface Suspend { long value() default -1; } import javax.ws.rs.core.Response; public interface AsynchronousResponse { void setResponse(Response response); } The @Suspend annotation tells Resteasy that the HTTP request/response should be detached from the currently executing thread and that the current thread should not try to automaticaly process the response. The argument to @Suspend is a timeout in milliseconds until the request will be cancelled. The AsynchronousResponse is the callback object. It is injected into the method by Resteasy. Application code hands off the AsynchronousResponse to a different thread for processing. The act of calling setResponse() will cause a response to be sent back to the client and will also terminate the HTTP request.