Giter Site home page Giter Site logo

spring-cloud-demo's Introduction

spring-cloud-demo

Demonstrate micro service architecture implemented using Spring cloud.

There are 6 services in this demo, serving different contents

  1. config-server: serves configuration to all services
  2. discovery-server: discovery server implemented using netflix-eureka
  3. user-service: serves users details
  4. photo-service: serves photo details
  5. comment-service: serves photo details
  6. gateway: Gateway service which provides api's end points and collects content from required services to serves to users

What is Config Server

In cloud environment configuration can be kept centralized. Spring cloud provides config-server which can fetch configuration from version control systems like git or svn and from file system as well. In this demo directory configserver contains config-server which is configured to use this git repository for storing config files. all config files are kept in config folder.

What is discovery-service

Discovery service is responsible for registering and providing

  1. Location of different services
  2. Status of different services, whether they are running or is down In this demo directory discoveryserver contains discovery-service which is implemented using Netflix's Eureka. Spring boot makes it super easy to implement it using spring-cloud-starter-netflix-eureka-server.

MySql has been used as database for storing and fetching data. use all.sql file to populate databases. There are three databases:

  1. User: contains users data
  2. Photos: contains photo's data
  3. Comments: contains comment's data

All services uses common module data and dao for connecting and fetching data from database.

How to run

First of all build the project using maven from the root of the project. Run below command maven clean install -DskipTests

Note: By default spring plugin runs the tests as i have added dependencies. Tests will be added later on, so for now skip tests

Run services in below sequence

  1. Discovery server from discoveryserver directory using command mvn spring-boot:run
  2. Config server from configserver directory using command mvn spring-boot:run
  3. Now you can run rest services from their respective directories using command mvn spring-boot:run

Collecting traces using zipkin

This demo is configured to extract trace information using zipkin. Spring cloud provide a utility named slueth which exports trace information from your service to zipkin which shows the time taken to communicate between different services

Download zipkin from https://search.maven.org/remote_content?g=io.zipkin.java&a=zipkin-server&v=LATEST&c=exec and run using command java -jar zipkin-server-<version>-exec.jar (replace version or correct jar file name)

Now open Eureka service from url http://localhost:8761/ This should show all registered services Access user's detail from url http://localhost:8080/users. This should return a list of users

Access trace logs from zipkin http://localhost:9411

spring-cloud-demo's People

Contributors

kgcorner avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.