Async all the way down
An opinionated, asynchronous, reactive Dropwizard microservice. Uses:
- Asynchronous JAX-RS server via RX
- Asynchronous JAX-RS client via RX
- Chunked responses via RX
Flowable
s - Asynchronous Postgres driver
How to try it out
- Make sure you have Docker set up and working (it uses TestContainers to start a Postgres instance)
- Open in your IDE
- Run the
DemoTest
test to start the server over a temporary database instance - Once the test is up and running, call the following endpoints from your browser:
http://localhost:8081/demo/write
to write 100 records to the database, returning them to the browser immediately as they are writtenhttp://localhost:8081/demo/read
to read the records back in the same wayhttp://localhost:8081/demo/readhttp
to read the records back via the above endpoint via an HTTP client - again streaming in real time.http://localhost:8081/demo/count
to read the record counthttp://localhost:8081/demo/reset
to delete the records
Note that responses are streamed back (deliberately slowed down to show chunked responses in progress) and don't block a server thread. The database I/O doesn't block a worker thread either - both use NIO, so you don't need a large thread pool to support high volume.
It's all magic
Check out the JAX-RS Resource - note that all this is achieved largely transparently as long as you write the endpoints using reactive logic.