Skip to content
This repository has been archived by the owner on Sep 29, 2021. It is now read-only.

Latest commit

 

History

History
82 lines (51 loc) · 5.16 KB

README.md

File metadata and controls

82 lines (51 loc) · 5.16 KB

Java - reactive backend examples

As of September 2021 this repository is no longer actively maintained by the GOV.UK Pay team.

This repository contains a collection of examples/patterns that can be adopted to make a java based micorservice reactive.

GOV.UK Pay, a payment platform for the government consists of many microservices. Our backend is RESTFUL by default, and we use Dropwizard for most of java based microservices. Dropwizard is based on Jetty, a lightweight java http/servlet container. Architecturally, jetty is a thread based synchronous (blocking) request processing container, similar to many other traditional java servlet containers.

Over the last decade or so, asynchronous/non-blocking request processing architectures are gaining huge traction across the industry, primarily due to the capabilities of optimum usage of available resources (H/W, S/W) allowing significantly higher throughput. Although this model already been widely used in other (non-java) tech stacks (e.g. NodeJs, Scala/Akka), it has been a slow progress in Java community due to its lack of language features (functional) and lack of libraries / frameworks. However, with the introduction of Java 8 features and the appearance of several reliable libraries/frameworks (e.g. guava listenable futures, Rx Java, Akka) Java landscape is slowly shifting towards asynchronous non-blocking programming models.

The biggest challenge yet is the change of mentality among the developer community from a more traditional synchronous programming models to more functional / reactive programming models in order to gain the advantages these recent developments.

This repository presents few alternative non-blocking programming models / patterns and technologies for Java. We expect to adopt these (and possibly more) as we extend GOV.UK Pay in future.

Further Reading

Examples.

####1. Handling inbound requests

alt handling inbound requests

This is about how to handle HTTP/REST requests in a non-blocking way.

####2. Handling outbound requests

alt handling outbound requests

This is about how to handle outbound HTTP/REST requests in a non-blocking way.

####3. Handling internal workflows

alt internal workflows

This is about how we can compose a internal workflow of bunch of functions together in a reactive way.

####4. Decoupling of microservices using an event source

alt decoupling

This is about how we can compose a internal workflow of bunch of functions together in a reactive way.

###References

  1. RxJava rxjava
  2. Hystrix hystrix
  3. Guvava LitenableFutures Guvava
  4. Jersey
  1. Ratpack Ratpack
  2. Java8 CompletableFuture

Other options (not explored)

  1. VertX vert.x
  2. Akka akka