Skip to content

Testing spring cloud projects (netflix, sleuth, etc.) in a microservice environment

Notifications You must be signed in to change notification settings

stackdocker/spring-cloud-netflix-sample

 
 

Repository files navigation

Spring Cloud Netflix Sample

Table of contents

Project msa-sms - a Spring Cloud Web Service Demo

Service Discovery - netflix Eureka

Client side Load balancing - netflix Ribbon

API Gateway - netflix Zuul

Circuit Breaker - netflix Hystrix & Turbine

Project msa-sms

Swagger 屏幕快照 2017-07-15 下午12.34.44.png

Build with mvn - build.txt

Run into console - run.txt

JAXB of WSDL - WSDL.md

JAX-WS schema - XSD.md

Microservice

This project is intended to be a test and practical example of several spring cloud technologies, namely:

  • Service discovery via Eureka server or Consul Server
  • Client side balancing using Ribbon
  • Edge server using zuul
  • Circuit breaker using Hystrix
  • Real time monitoring using Hystrix Dashboard + Turbine
  • Log correlation using sleuth

We also use other interesting technologies

  • Swagger to document microservices API
  • Examples on how to serialize and document new java.time classes

There are two maven profiles defined to choose between consul and Eureka. Eureka profile is active by default.

Service discovery via Eureka server

Build project using:

mvn clean package

Service discovery via Consul server

Build project using:

mvn clean package -P -discoveryServiceEureka,discoveryServiceConsul

The run script presupposes that you have consul installed and runs a local development instance.

It uses tags to select instances to be called (i.e. mirroring AWS availability zones).

Client side balancing using Ribbon

Edge server using zuul

Exposed endpoints: http://localhost:8080/microserviceOne/testCallOne http://localhost:8080/microserviceTwo/testCallTwo

Circuit breaker using Hystrix

Real time monitoring

Real time monitoring using Hystrix Dashboard + Turbine to aggregate all monitoring streams in a single Dashboard.

Turbine works with consul but still lacks metadata functionality to specify customs CLUSTER keys

Log correlation using sleuth

Adding spring.cloud.sleuth dependency we get a consistent TraceId added to all the logs in all microservices, and we also get the following header in the JSon response: X-B3-TraceId: c058d819e6499487

Using swagger to document microservices API

Online documentation and tester available at: http://localhost:xxxx/swagger-ui.html JSON swagger API specification available at: http://localhost:xxxx/api-docs/

How to run test sample

Use run-test-suit-[eureka|consul].sh to start the test (in a local machine environment). The script uses cygwin, although it shouldn't be difficult to change to a linux environment.

Interesting Links

Hystrix

Turbine

Swagger and SpringFox

About

Testing spring cloud projects (netflix, sleuth, etc.) in a microservice environment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 93.6%
  • Shell 6.4%