Skip to content

Main repository for the workshop `From Monoliths to Microservices using CQRS and Event Sourcing`

License

Notifications You must be signed in to change notification settings

manuel-alvarez-alvarez/microservices-workshop

Repository files navigation

From Monoliths to Microservices using CQRS and Event Sourcing Download

Introduction

In a Microservices architecture state is distributed across many applications and databases. Keeping all the microservices consistent is a non trivial task and here is where CQRS and Event Sourcing really shine.

In this workshop we will move from a terrible Monolith to a nice Microservices app using CQRS/ES as the middle man. The recipe to Microservices that we will follow here will be:

  1. Start with an ugly Monolith.
  2. Add some CQRS and ES to the Monolith using Spring Streams and Apache Kafka.
  3. Break your CQRS Monolith into small microservices using Spring Cloud.

Prerequisites

Git

You must have a working installation of GIT in your machine (Git Downloads)[https://git-scm.com/downloads]. You can test that it works by running the following command:

$ git clone https://github.com/manuel-alvarez-alvarez/microservices-workshop.git

By the way, it will clone the main repository for the workshop (two birds one stone).

JDK 8

Make sure you have a working installation of the JDK 8 in your machine (Java SE Development Kit 8 Downloads). You can test it by running the following command in a console:

$ javac -version

Docker

You must have a working installation of Docker as well, the community verison will work just fine (Download Docker Community Edition). You can test it by running the following command in a console:

$ docker run docker/whalesay cowsay Ready to rock

You should see something like this:

 _______________
< Ready to rock >
 ---------------
    \
     \
      \
                    ##        .
              ## ## ##       ==
           ## ## ## ##      ===
       /""""""""""""""""___/ ===
  ~~~ {~~ ~~~~ ~~~ ~~~~ ~~ ~ /  ===- ~~~
       \______ o          __/
        \    \        __/
          \____\______/

In order to prevent downloading too much data the day of the conference I recomment you to prefetch some of the docker images we are going to use:

$ docker pull openjdk:8-alpine
$ docker pull wurstmeister/zookeeper:3.4.6
$ docker pull wurstmeister/kafka:0.10.2.1

Remember to install docker-compose if it's not installed by default (Install Docker Compose). . You can test it by running the following command in a console:

$ docker-compose -v

Information. In a linux machine docker commands require sudo but you can manage it as non-root user following this guide.

Domain

Disclaimer. All resemblance with reality is pure fiction, nothing shown here is accurate from a physics point of view.

The purpose of this workshop is to build a particle detector that will try to find evidence of the theoretical particle called Chameleon. The current Standard Model includes the following particles:

Standard Model

The workshop will provide you an accelerator that will send snapshots every 5 seconds to a kakfa instance containing the lists of detected particles in the different experiments. For each deteced particle you will find the following information:

  1. The experiment where it was detected
  2. The spin of the particle
  3. The charge of the particle
  4. The mass in MeV/c2 (it's always an exact number, e.g. for an electron it will always be 0.511MeV/c2 and for the tau neutrino it will be 15.5 MeV/c2)

The tool we are about to build should:

  1. Detect collisions inside snapshots. A collision happens when three or more particles are detected in the same experiment
  2. Analize each one of the collisions and get the type of the particles to find the elusive chameleons

Workflow

As stated before, we are going to follow the next steps in the workshop:

  1. Build a monolith in order to get used to the domain and some technologies we will use later
  2. Convert the monolith ot a CQRS/ES application
  3. Break the CQRS/ES application into different microservices

In order to do it there are several branches (the ones with the suffix _start are the starting point for the step, and the ones with _end contain my very own lousy solution).

  • Monolith
  1. git checkout monolith_start
  2. git checkout monolith_end
  • CQRS/ES
  1. git checkout cqrs_start
  2. git checkout cqrs_end
  • Microservices
  1. git checkout microservices_start
  2. git checkout microservices_end

So let's start buidling the Monolith

$ git checkout monolith_start

About

Main repository for the workshop `From Monoliths to Microservices using CQRS and Event Sourcing`

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published