• Stars
    star
    357
  • Rank 115,225 (Top 3 %)
  • Language
    Java
  • License
    MIT License
  • Created about 7 years ago
  • Updated 25 days ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A full microservice architecture with Java, Spring Cloud, Log management with ELK, Server load balancing with Nginx, Infrastructure management with Docker-compose, JMX application monitoring, JWT, Aspect OP, Distributed events with Kafka, Event Sourcing, CQRS, REST, Web Sockets, Continuous deploy with Jenkins and more

Bootstrap project to work with microservices using Java

Watch the videos demonstrating the project

Bootstrapping a microservice architecture

Read about the project here

The idea of this project is to provide you a bootstrap for your next microservice architecture using Java. we are addressing main challenges that everyone faces when is starting with microservices. This project will definitely help you get an understand about microservices world and save you a lot of time in setting your initial microservice architecture.

Basically, if you are interested in microservice, either study or want to implement microservice approach at your work, this project is for you!

Microservice principles addressed:

  • Scalability
  • Availability
  • Resiliency
  • Independent, autonomous
  • Decentralized governance
  • Failure isolation
  • Auto-Provisioning
  • Continuous delivery through DevOps

Microservice patterns:

  • Circuit Breakers
  • API Gateway
  • Command Query Responsibility Segregation (CQRS)
  • Saga Pattern
  • Event Sourcing
  • Log Aggregation
  • Health Check
  • Service Discovery
  • External Configuration
  • Distributed authentication

Free Advanced Java Course

I am the author of the Advanced Java for adults course. This course contains advanced and not conventional lessons. In this course, you will learn to think differently from those who have a limited view of software development. I will provoke you to reflect on decisions that you take in your day to day job, which might not be the best ones. This course is for middle to senior developers and we will not teach Java language features but how to lead complex Java projects.

This course's lectures are based on a Trading system, an opensource project hosted on my Github.


Technologies that you will see in this system:

Spring Boot, Spring Data, Spring Cloud Eureka, Load Balancing with Ribbon, Declarative REST Clients with Feign, Software Circuit Breakers with Hystrix, Administrating using Spring admin,Log management with Elastic search, Logstash and Kibana (ELK), Server load balancing with Nginx, Infrastructure management with Docker-compose, JMX application monitoring, Security with Spring Security OAuth, Oauth2 with JWT, Aspect Oriented Programing, Distributed events with Kafka, Spring Stream Maven Multimodule project, Event Sourcing, CQRS, REST, Web Sockets, Continuous deploy with Jenkins, and all developed using Java 8.

Alt text

How to use

  • run package-projects.sh
  • run docker-orchestrate.sh
  • docker-compose -p todo up

Continuous deploy using Jenkins Pipeline

We have created a docker image in order to have continuous deploy in our project here.

This image will contain all necessary to build our project, create the Docker images and deploy on AWS using ECS containers.

To make this integration easy, we have added the Jenkinsfile with the steps necessary to have the Docker image built. To use it, you will need just to configure a Job on Jenkins using Pipeline plugin and paste the content of the Jenkinsfile in the Pipeline script box. Have a look at this video to check how to work with Jenkins pipeline

Deploy on AWS

  • Create your credentials on AWS
  • Create your cluster on AWS console
  • Have the build-deploy container running (Checkout in the project's README how to do it)
  • Access Jenkins painal
  • Create a pipeline job
  • Run the Job

Accessing the services

  • Authenticate -> curl -X POST -vu todo-app:123456 http://localhost:8017/oauth/token -H "Accept: application/json" -d "password=1234&[email protected]&grant_type=password&scope=write&client_secret=123456&client_id=todo-app"

  • Get data using the access_token -> localhost:8018/accounts?access_token={access_token} or curl -H "Authorization: Bearer $TOKEN" "localhost:8018/path"

Scaling

NGINX will be configured for browser caching of the static content and Load balance. For that we will need to scale our App Gateway and update manually the ports in default.conf file, in the upstream configuration section:

upstream backend {
  server gateway:8018;
  server gateway:DYNAMICPORT;
  server gateway:DYNAMICPORT;
}

And we will run the compose file with --scale parameter:

docker-compose -f proxy-docker-compose.yml -p todo up --scale gateway=2

URLs

Monitoring stream - http://localhost:8022/turbine.stream

To-dos http://localhost:8015/todos

Users http://localhost:8016/accounts

Eureka server - http://localhost:8010/

Config server - http://localhost:8888/

Boot admin - http://localhost:8026

Kimbana - http://localhost:5601

Elasticsearch Info: http://localhost:9200

Elasticsearch Status: http://localhost:9200/_status?pretty

NGINX Status: localhost:8055/nginx_status

docker-compose -p todo up docker-compose -p todo down

OBS

  • In order to make ELK work we need to reserve 3GB RAM to docker(docker settings - advanced - memory )
  • Have a look at the Readme of each service/ module to see the explanation about it.
  • On Kimbana create a filter called filebeat-* to see the logs

Useful Commands

Creating to-do via Curl

curl -d '{"userEmail":"[email protected]", "caption":"post caption", "description":"desc", "priority": 1}' -H "Content-Type: application/json" -X POST http://localhost:8015/todos

Stopping, Starting, Restarting...

# running separated container and link to the network infrastructure
docker run -d -p 8018:8018  --network todo_net --add-host eureka:172.19.0.5 --add-host config:172.19.0.2 todo/reminder-service

# orchestrate start-up of containers, tailing the logs...
docker-compose -p music up -d container-name && docker logs elk --follow # ^C to break

# stopping containers
docker-compose todo stop
docker-compose todo down

# starting containers
docker-compose -p todo up

# removing containers
docker-compose todo rm

Application Startup Issues

# stop / start Tomcat
docker exec -it container-name sh /usr/local/tomcat/bin/startup.sh
docker exec -it container-name sh /usr/local/tomcat/bin/shutdown.sh

# check logs for start-up issues...
docker exec -it container-name cat /usr/local/tomcat/logs/catalina.out
docker logs container-name

Kafka

Inside the Kafka container

# event consume
/opt/kafka/bin/kafka-console-consumer.sh --zookeeper zookeeper:2181 --topic todo-mail --from-beginning

# producer console
/opt/kafka/bin/kafka-console-producer.sh --broker-list kafka:9092 --topic todo-mail

# Listing topics
/opt/kafka/bin/kafka-topics.sh --list --zookeeper zookeeper:2181

# Create topic
/opt/kafka/bin/kafka-topics.sh --create --zookeeper zookeeper:2181 --replication-factor 1 --partitions 1 --topic pcs

Data

#create a new To-Do 
curl -H "Content-Type: application/json" -X POST -d '{"id":161,"caption":"Test caption 3","userEmail":"[email protected]","description":"description 3","createdat":null,"priority":2,"status":"PENDING","version":0,"valid":true}' http://localhost:8015/todos

TODO

  • Add private maven repository Artifactory
  • Manager services integration through Spring Webflow
  • Add Distributed Tracing

That's all. Leave a star if it helped you!

More Repositories

1

grpc-production-go

A gRPC production-ready library
Go
189
star
2

big-data-pipeline-lambda-arch

A full big data pipeline (Lambda Architecture) with Spark, Kafka, HDFS and Cassandra.
Java
161
star
3

chatflow

Leveraging LLM to build Conversational UIs
TypeScript
110
star
4

trading-system

An open-source backtesting and live trading platform for using to foreign exchange
Java
64
star
5

modern-api-management

A modern approach to manage APIs effectively using Protobuf
Shell
52
star
6

service-mesh-istio

A microservice project leveraging Service Mesh with advanced features from Istio
41
star
7

smart-drone

This project leverage Machine learning/Computer vision to make a low-cost Drone smarter and autonomous.
JavaScript
24
star
8

computer-vision

A collection of computer vision projects
Jupyter Notebook
19
star
9

neuroevolution

In this project we combine Artificial Neural Network and Genetics Algorithms to build powerful AI
JavaScript
15
star
10

neuralnet-browser

Artificial Neural Network from scratch using Javascript on the browser
CSS
11
star
11

cnn-for-devs

A project to teach Convolution Neural Network for devs
Jupyter Notebook
10
star
12

grpc-production-java

A Grpc server production ready example
Java
8
star
13

build-deploy

A build deploy docker image to work with Java application and AWS
Shell
5
star
14

istio-and-minikube

Customizable Istio installation for Minikube
4
star
15

image-edit

Image handler
PHP
3
star
16

k8s-microservices

The state of the art in microservices
Shell
3
star
17

admin2014

Meu admin
JavaScript
2
star
18

githooks

Easy to use git hooks
Shell
2
star
19

trading-robot

A strategy to bit the Fx market
Python
2
star
20

helpers

MInhas classes helpers que me ajudam no dia a dia
PHP
2
star
21

apssouza22

About me
2
star
22

video-chat-rtc

This is a video chat app using WebRTC and WebSockets. It is built using Node.js, Express, and Socket.io.
JavaScript
2
star
23

portfolio

Desenvolvimento do meu portfolio profissional
JavaScript
2
star
24

chat-commander-ui

JavaScript
2
star
25

lambda-integration-test

Project example of lambda integration test with AWS CDK + SAM + Docker + Docker-compose + Mock server
TypeScript
1
star
26

protobuf-gen-code

Generated Go code from the Protobuf-api-management repo
1
star
27

noblocking

Testing noblocking IO with PHP, using socket and curl
PHP
1
star
28

tmc

PHP
1
star
29

js-canvas

Projetos diversos usando canvas
JavaScript
1
star
30

shell-script

Meus shell-scripts que me ajudam no dia a dia
Shell
1
star
31

project-setup

An example of a Java project setup
Java
1
star
32

js-inputsearch

Javascript que facilita a busca a partir de uma fonte de dados local ou remota
JavaScript
1
star
33

blog

My blog posts
SCSS
1
star
34

java-effective

Example of a Todo project using JEE features
Java
1
star
35

angular2

Some Angular test projects
JavaScript
1
star
36

js-validate

Uma versão simples de plugin de validação
JavaScript
1
star
37

spl-navidareal

Exemplos de funcionalidades da SPL que utilizo no meu ciclo de desenvolvimento
PHP
1
star
38

gauge-python-api-example

Using Gauge and Python to test REST API
Python
1
star
39

spring-modules

Working with maven modules
Java
1
star
40

eta-chome-extension

A chrome extension to help test Eta UI
JavaScript
1
star
41

js-tab

Classe que facilita o trabalho com abas
PHP
1
star
42

html5_experience

Experiencias em html5 + responsive designer + facebook
JavaScript
1
star
43

js-sexy

Projetos diversos de javascript
JavaScript
1
star
44

my-dao

Minha estrutura de classes de abstração de banco de dados
PHP
1
star
45

first-java-project

Códigos do primeiro projeto Java versão simplificada
Java
1
star