Building a reactive web service with Spring Webflux, Kotlin, and PostgreSQL
This post shows how to create a reactive web service with Spring Webflux, Kotlin, PostgreSQL
For the context, Spring Framework 5 introduced the so-called Reactive Stack. The keyword
reactive
refers to the Reactive Manifesto, which is a specification for asynchronous stream processing with non-blocking back-pressure. This specification is a joint collaboration between engineers from Netflix, Pivotal, Red Hat, Twitter and many others. It has been implemented in many languages such as: Java, Javascript, Swift, NET, etc.In short, Spring Webflux is a non-blocking web framework that uses Reactor library, which implements the Reactive Streams Specifications, to asynchronously manage HTTP requests.
Requirements
Say we want to build an HTTP service that can do the following:
curl -XPOST /api/users/create -d '{"name": "some-name", "email": "some-email"}'
curl -XPOST /api/users/fetch -d '{"user_id": 123}'
curl -XPOST /api/users/all
Note: the final code repo is here: