2017-11-10

Java: Jersey-server Async

Have you heard about Jersey's @ManagedAsync annotation?

What does it give? Well, it automagically runs the resource method in a separate thread, hosted by Jersey's own ExecutorService.
This way you don't have to do a boilerplate executor pattern for your every resource method.

When is this useful: If you expect blocking IO during handling the request, this way you can easily offload the execution into a different thread that can block as much as it wants.

For beautiful examples, see this blog post.

No comments :

Post a Comment