About
Java - Rest with vertx
The problem
Many wrapper libraries (Rest, CDI, …) use a thread-local context so that the user-code method can look them up when executed.
In the case of RESTEasy, the context holds this information:
- the current request,
- response
- and many other useful information
This works well where you have one thread per request, but stops working if the request:
- spawns other threads (as is the case in many Reactive libraries, such as RxJava)
- gets executed in other threads
because the context is not made available in this thread.
The solution are:
- Introducing a reactive_context
JaxRS
Rest Easy as Router
RESTEasy is this case is the router and you can't add a route without it which means that you server is only a rest server.
Reactive Context
reactive-contexts propagates the context to multi-thread allowing resteasy to work.
See also the Redpipe framework that is based in this idea.