Skip to content
This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
/ vis-lab Public archive

Splitting a monolithic web shop application from Tomcat into microservices with Spring Boot and Docker. This project is part of the masters course 'Distributed Information Systems' at the University of Applied Sciences (Karlsruhe)

License

Notifications You must be signed in to change notification settings

mavogel/vis-lab

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT license Travis Build Status

Distributed Information Systems Laboratory aka vis-lab

Splitting a monolithic web shop application, running on a Tomcat into small domain-driven microservices with Spring Boot and Docker. This project is part of the masters course 'Distributed Information Systems' at the University of Applied Sciences (Karlsruhe).

Prerequisites

Starting

Legacy System

  • Start Docker daemon
  • Check out the project, export variables and simply run the script:
$ chmod +x run_legacy.sh
$ ./run_legacy.sh
  • Builds the web app war, packs it into a docker tomcat8 container, and sets the user tomcat with password admin for the Management Console at http://localhost:8888/
  • Inits the MySQL Database docker container with the db user defined in hibernate.cfg.xml
  • Sets up both containers and make the legacy webshop available under http://localhost:8888/EShop-1.0.0/

Microservice Architecture

  • Start Docker daemon
  • Check out the project and simply run the script:
# Build all microservices, create docker images and start them
$ ./run_microservices.sh
# for shutting down
$ ./shutdown_microservices.sh

Useful links

  • Eureka service registry: http://localhost:8761/
  • Zuul Gateway routes: http://localhost:8765/routes

Note: run e.g. curl -D- -X GET localhost:8765/category first, so hystrix produces stream data

  • Local Monitoring Dashboard for Composite: http://localhost:8084/hystrix -> enter url http://localhost:8765/hystrix.stream
  • Monitoring Dashboard Service: http://localhost:7979/hystrix
    • cat comp: http://categorycompositeservice:8080/hystrix.stream
    • gateway: http://api-gateway:8765/hystrix.stream

curl statements for testing:

  1. Obtain the access token and refresh token for the grand_type=password via one of the three methods:
  • curl -v -H "Authorization: Basic $(echo -n 'acme:acmesecret' | base64)" http://localhost:8765/uaa/oauth/token -d grant_type=password -d username=admin -d password=admin
  • curl -v -u acme:acmesecret http://localhost:8765/uaa/oauth/token -d grant_type=password -d username=admin -d password=admin
  • curl -v http://acme:acmesecret@localhost:8765/uaa/oauth/token -d grant_type=password -d username=admin -d password=admin
  1. Save the obtained access token in the ACCESS_TOKEN env var: export ACCESS_TOKEN=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE0ODQ0ODExM...

  2. Perform requests

  • curl -v 'http://localhost:8765/category' -i -X GET -H 'Content-type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN"
  • curl -v 'http://localhost:8765/category' -i -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN" -d '{"name":"TestCategory"}'
  • curl -v 'http://localhost:8765/product' -i -X GET -H 'Content-type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN"
  • curl -v 'http://localhost:8765/product' -i -X POST -H 'Content-Type: application/json' -H "Authorization: Bearer $ACCESS_TOKEN" -d '{"name":"NewProduct", "price":"1.00", "category":"1", "details":"fancy details"}'
  • curl -v 'http://localhost:8765/user/admin' -i -X GET -H "Authorization: Bearer $ACCESS_TOKEN"
  • curl -v 'http://localhost:8765/user/register' -i -X POST -H 'Content-Type: application/json' -d '{"username":"jdoe", "firstname":"John", "lastname":"Doe", "password":"s3cr3t"}'

Debugging:

Check MySQL contents

  • Connect to container: docker exec -it <#containerId> bash
  • Connect to db: mysql -h localhost -D webshop -u webshopuser -p240b2c6d58ff2ce2f508b49f

API Documentation

The documentation of the services

  • CategoryService
  • ProductService
  • UserService is available at the api-gateway: http://localhost:8765/docs/api-guide.html

Notes

If you change the user and password of the MySQL database, you should run

$ docker-compose -f docker-compose-legacy.yml rm -v
$ rm -rf .data

Details can be found here

About

Splitting a monolithic web shop application from Tomcat into microservices with Spring Boot and Docker. This project is part of the masters course 'Distributed Information Systems' at the University of Applied Sciences (Karlsruhe)

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages