A microservice is a small, independent piece of software that performs a specific function. They might be retrieving data from a database, processing an incoming request, or generating a report.
They are designed to be modular so that they can be easily integrated into larger systems. They can be viewed like bricks or pieces in a jigsaw which are brought together to make something useful.
An asynchronous microservice receives events and responds that the event has been received. Once the event has been processed, the microservice sends its output to the next stage in the event flow, allowing other microservices to be then invoked. This is called loose coupling between the microservices.
Asynchronous microservices are preferable to synchronous microservices because this loose coupling increases an architecture’s resiliency to failure and ability to handle traffic spikes.
The first microservice in an event flow may query a database. The next microservice may use the returned data to complete a piece of functionality, for example, to calculate the age of a user or create a social connection with another user.
Microservices should simply append any new data to the initial input event and then pass that extended data onward to the next microservice. A single microservice can be used in multiple different event flows and therefore does not know who or what data is required further down the line.
{ "input":{ "User_ID": "123" }}
{ "input":{ "User_ID": "123" } "User":{ "ID": "123" "Name": "Jim" "YearOfBirth": "2000" "CountryOfResidence": "FR" }}