3. Microservices Rest


In the previous lab we inspected the monolithic application. In this lab we will distribute the monolith in two independent microservices.

Both microservices will use RESTful APIs to communicate with each other. We build the order microservice and see why data consistency could be violated.

In a last step we will have a look at the MicroProfile Long Running Actions (LRA)1 and how this could help for data consistency. At the end we will see how a SAGA orchestration approach could be built using LRA.

Splitting the Monolith

We will split our monolith in the two contexts order and stock. The order microservice will manage the orders. The stock microservice will manage the article stock and will decrement the available stock if there is a new order.

We expect the stock count of an article to be consistent with its order count.

Monolith Split

Can you imagine another context which exists in the monolith?


Think of a rich article catalog with pictures, thumbnails and a detailed description. There is a high chance that this would be managed in another independent microservice.

Lab Overview

In the first version we will use the two microservice order and stock.

In a second version we will introduce the lra-coordinator and our environment will look like this.


  1. Eclipse MicroProfile LRA: https://github.com/eclipse/microprofile-lra/blob/master/spec/src/main/asciidoc/microprofile-lra-spec.adoc ↩︎

3.1 Getting Started

Getting started with the lab environment.

3.2 Docker Environment

Setting up your local docker environment for this lab.

3.3 Building a Microservice

Understand the setup and build your own order microservice.

3.4 Running the Lab

Building the docker image for the order microservice and start the environment.

3.5 Using the Lab

Making requests against the Lab environment.

3.6 Distributed Transactions

Understand how we can provide data consistency over multiple microservices.