Asynchronous REST API with Jersey Asynchronous REST API with Jersey multithreading multithreading

Asynchronous REST API with Jersey


Why does Jersey's async design force developer to offload REST processing to separate thread/runnable, while Jersey can do this by itself with a dedicated/private executor pool?

You're not forced to. Jersey has the @ManagedAsync that you can put on your methods. This does exactly what you are asking

ManagedAsync

Indicates that the resource method to which the annotation has been applied should be executed on a separate thread managed by an internal Jersey executor service.

@GET@ManagedAsyncpublic void longGet(@Suspended final AsyncResponse ar) {    }

See Also: