Skip to content

olegyev/learn-microservices-multiplicator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Training microservices project - core

Simple training project to learn microservices.
This repository is for the core User and Challenge services.

Source of knowledge:

https://github.com/Book-Microservices-v2

Related repos:

Idea:

A user solves multiplication challenges with factors between 11 and 99. For example, 30x60.
Results and leaderboard are displayed.

Technologies:

  • Java 14
  • React.js
  • Spring Boot 2
  • Spring Cloud (Gateway, Consul, Load Balancer, Sleuth)
  • Lombok
  • Logback
  • MongoDB
  • JUnit 5
  • Mockito
  • AssertJ
  • RabbitMQ
  • Consul (service registry, health checks, load balancing, centralized configuration/logging)
  • Docker
  • Docker Compose

To boot in dev mode:

  1. Install JDK 14.
  2. Install MongoDB - see here.
  3. Create MongoDB cluster which supports sessions (transactions) - see here.
  4. Install RabbitMQ server - see here.
  5. Enable RabbitMQ GUI manager using this command:
    $ rabbitmq-plugins enable rabbitmq_management
    Will be available via http://localhsot:15672
    If needed, RabbitMQ server can be run manually from within the RabbitMQ sbin command prompt (run as administrator): $ rabbitmq-server start
  6. Install Consul by HashiCorp as a Service Registry - see here.
  7. To run Consul in dev mode, use the following command: $ consul agent -node=learnmicro -dev
    If port is occupied on Windows, use the following commands:
    $ netstat -ano | findstr :\PORT\
    $ taskkill /PID \PID\ /F
  8. Consul GUI is available via http://localhost:8500
    NOTE! While adding YAML properties to the Consul KV using the Consul GUI, use 4 spaces instead of tab for indentation.
    NOTE! While adding {application},{profile} property using the Consul GUI, need to literally name folder using separator (comma ',' by default; to change separator, specify spring.cloud.consul.config.profile-separator within bootstrap.properties).
    Example: config/defaults,production/application.yml; config/multiplicator,rabbitmq-production/application.yml
    To run application specifying active profiles, use the following command: $ ./mvnw spring-boot:run '-Dspring-boot.run.arguments="--spring.profiles.active=rabbitmq-production,production"'
  9. To run the new microservice's instance use the following command from within the microservice's directory:
    $ ./mvnw spring-boot:run -Dspring-boot.run.arguments="--server.port=\PORT\"
  10. To run front-end, install Node.js and npm - see here.
  11. To run front-end in the dev mode, use the following command from within the front-end application's directory:
    $ npm start

To boot as local containers using Docker:

  1. Install Docker - see here.
  2. Prepare JAR from within the root folder of the multiplicator service:
    NOTE! This command can be used for all the services mentioned below:
    $ ./mvnw clean package
    NOTE! All the services mentioned below may require running Consul agent to build Docker image properly (see previous section):
    $ consul agent -node=learnmicro -dev
  3. Build Docker image for the multiplicator service from within its root folder:
    $ docker build -t multiplicator:\VERSION\
    NOTE! Version should be provided as #.#.# (e.g. 1.0.0).
    If changed, need to update also in Docker Compose file - see here.
    NOTE! If project's version tag is changed in POM.xml, need also to edit Dockerfile's COPY command.
  4. Prepare JAR from within the root folder of the gamification service.
  5. Build Docker image for the gamification service from within its root folder:
    $ docker build -t gamification:\VERSION\ .
  6. Prepare JAR from within the root folder of the gateway service.
  7. Build Docker image for the gateway service from within its root folder:
    $ docker build -t gateway:\VERSION\ .
  8. Prepare JAR from within the root folder of the logging service.
  9. Build Docker image for the logging service from within its root folder:
    $ docker build -t logs:\VERSION\ .
  10. Build Docker image for the frontend service from within its root folder:
    $ docker build -t challenges-frontend:\VERSION\ .
  11. Build Docker image for the Consul importer service (serves only to import initial configurations by the Consul, exits immediately after completing this task):
    $ docker build -t consul-importer:\VERSION\ .
  12. Run the complete system using Docker Compose from within the dockerization folder:
    $ docker-compose up
  13. To stop the whole application and completely remove the containers, use the following command from a different terminal:
    $ docker-compose down -v
  14. To start additional service's instances, use the following command:
    $ docker-compose up --scale \IMAGE_NAME\=\INSTANCES_AMOUNT\

About

Simple training project to learn microservices - core service

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published