We are using Jersey for a REST webservice (deployed on tomcat).
I know that
I read here that Jersey provides AsyncService
to maximise concurrency.
Question: 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?
Is this for better control for developer or am I missing something here?
REST clients can be implemented either synchronously or asynchronously. Both MicroProfile Rest Client and JAX-RS can enable asynchronous clients.
Jersey is Sun's production quality reference implementation for JSR 311: JAX-RS: The Java API for RESTful Web Services. Jersey implements support for the annotations defined in JSR-311, making it easy for developers to build RESTful web services with Java and the Java JVM.
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
@ManagedAsync
public void longGet(@Suspended final AsyncResponse ar) {
}
See Also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With