centiservice / mats3

Mats3: Message-based Asynchronous Transactional Staged Stateless Services
https://mats3.io/
Other
63 stars 7 forks source link

Tool to make servlet/Spring @RequestMappings async by employing Mats #7

Open stolsvik opened 6 years ago

stolsvik commented 6 years ago

A requestmapping made with this tool would work as follows:

  1. In @RequestMapping, do initial parameter validation, e.g. auth/authz, sanity checking of params.
  2. Fire off, using the tool, a Mats flow using a modified version of the SynchronousAdapter logic. The tool would close over the async-context in the ".then()"-lambda on the CompletableFuture.
  3. Exit @RequestMapping
  4. When Mats returned and .completed() the CompletableFuture, the tool would take over again. I am not certain how the async-context works, but if the sending of the finished content possibly can block on network traffic (i.e. one goes back to synchronous processing regarding the output stream to the client browser), the finishing would have to be handed over to a new thread pool, of comparable size to the Servlet container's thread pool.