Clone all Projects together. Remember to switch to main branch instead of being into detached head.
git clone --recurse-submodules -j8 https://github.com/nitinkc/spring-microservices.git
cd spring-microservices
git submodule init
git submodule update
Read the Spring Modules that comprise the Spring Cloud
Diagram demonstrating the major components of Spring microservices Architecture
[test](###3. Conversion microservice)
Application | Port |
---|---|
Conversion microservice | 8000, 8001, 8002, .. |
Calculation microservice | 8100, 8101, 8102, … |
Netflix Eureka Naming Server | 8761 |
Netflix Zuul API Gateway Server | 8765 |
Zipkin Distributed Tracing Server | 9411 |
Test Config microservice | 8080, 8081, … |
Spring Cloud Config Server | 8888 |
Simple Spring Project that reads values from a DB and returns a conversion Factor for the consuming microservice
Group : com.microservices.learning.conversion
Artifact : conversion-service
Dependencies :
• Web
• Actuator
• dev tools
• config client
• jpa
• H2 Db
H2 DB Web Client URL : http://localhost:8000/h2-console/
Consumes Conversion micro service and performs x*value returned by conversion micro service operation to
Following technologies used :
- Rest template for consuming a rest microservices
- Declarative REST Client: Feign
- Ribbon Load Balancing
- Support for Eureka Naming Server (adds eureka client)
The rest calls are distributed using Ribbon & Eureka
- Zuul API Gateway integration
https://dzone.com/articles/microservices-communication-zuul-api-gateway-1
- Spring cloud sleuth : Provides a unique id to all the requests. Place the dependency to all the projects needing a unique request id
- Zipkin distributed Tracing server
Group : com.microservices.learning.calculation
Artifact : calculation-service
Dependencies :
• Web
• Actuator
• dev tools
• config client
-Dserver.port=8001
Group : com.microservices.learning.eureka
Artifact : eureka-naming-server
Dependencies :
• Eureka Server
• Config Client
• Spring Boot Actuator
• Spring Boot DevTools
Access Eureka Server UI at : http://localhost:8761/
Group : com.microservices.learning.zuul
Artifact : zuul-api-gateway
Dependencies :
• Zuul
• EurekaDiscovery
• Actuator
• DevTools
Has to be started in a terminal after starting Rabbit MQ server
- Rabbit MQ Should be installed and run
/usr/local/sbin/rabbitmq-server# Zipkin Distributed Tracing Server
* Rabbit MQ Should be installed and run
```sh
/usr/local/sbin/rabbitmq-server
- Install Zipkin Distributed Tracing Server from https://zipkin.io/pages/quickstart
- Run Zipkin server on terminal as
RABBIT_URI=amqp://localhost java -jar zipkin.jar
- Launch Zipkin server on terminal
- Eureka Naming Server
- Run the server on http://localhost:8761/
- Zuul API Gateway
- Command Service
- Run 3 instances with run/debug configurations with VM Options set for ports 8001, 8002
-Dserver.port=8001
- Run 3 instances with run/debug configurations with VM Options set for ports 8001, 8002
- Query Service with H2 inMemory DB
- Run 3 instances with run/debug configurations with VM Options set for ports 8101, 8102
-Dserver.port=8101
- Run 3 instances with run/debug configurations with VM Options set for ports 8101, 8102
- Rabbit MQ
- On Mac Install via brew
- Run on foreground : CONF_ENV_FILE="/usr/local/etc/rabbitmq/rabbitmq-env.conf" /usr/local/opt/rabbitmq/sbin/rabbitmq-server
- access the portal - http://localhost:15672/ with guest/guest
- Zipkin tracing server
- docker run -d -p 9411:9411 openzipkin/zipkin
- http://localhost:9411/zipkin/
<!-- Spring Cloud Config Client -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!--Feign Support Added-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- Ribbon Load Balancing added -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- Client for Eureka NamingServer -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!-- Spring Cloud Sleuth -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-sleuth</artifactId>
</dependency>
<!-- Zipkin Distributed Tracing Server added -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>
<!-- Rabbit Messaging Support added -->
<dependency>
<groupId>org.springframework.amqp</groupId>
<artifactId>spring-rabbit</artifactId>
</dependency>