RESTful microservices

When people shifted from monolithic to Microservices there was a paradigm shift. Suddenly everything became manageable. they consist of independently deployable, independently updatable services. These services each run a unique process and communicate through lightweight mechanisms to serve business goals.Microservices allow developers to work on individual components of the application, radically reducing the need for synchronized updates so that each component’s team can work on their own best schedule.

Issues in RESTful

The RESTful is not the holy grail of development. There are problems with this approach as well. As the number of microservices increases one needs special tools to keep watch for the state of microservices, their addresses and the biggest problem is transaction management.

There is also intra service communications which is client server communication making it synchronous communication. The above figure shows typical complexity of intra microservice communications. 

Solution

This is where streams come into picture. The approach is quite simple. We will just remove the intra service communication all together and switch all the communication via messaging bus. All the services will have a pub-sub model towards various topics they want. Streaming APIs are by their very nature stateful. Without storing state in some form, the Streaming API cannot properly contextualize the data relationship with the requesting client. In other words, clients typically open persistent connections with the streaming server in question. While this connection certainly has a limited lifespan, it is during this connection that the pushed content is delivered.

If REST APIs are a conversation, Streaming APIs are more akin to watching a movie in a movie theater – if REST is two people talking, a Streaming API is a person buying a movie ticket, sitting in a theater, and passively receiving the film

Bridging the Synchronous and Asynchronous Worlds

we can put all these ideas together in a more comprehensive ecosystem that validates and processes orders in response to an HTTP request, mapping the synchronous world of a standard REST interface to the asynchronous world of events, and back again.