Java - Rest with vertx
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,
- 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
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-contexts propagates the context to multi-thread allowing resteasy to work.
See also the Redpipe framework that is based in this idea.