Coder Social home page Coder Social logo

curioustauseef / microservices-example Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rkudryashov/microservices-example

0.0 1.0 0.0 524 KB

Example of a microservices architecture on the modern stack of Java technologies

License: Apache License 2.0

Kotlin 91.66% HTML 8.34%

microservices-example's Introduction

Build Status codecov

Microservices example

There are articles with more detailed explanation about this project: in English and in Russian.

This is an example of microservice architecture pattern implemented with following stack of Java-technologies:

  • JDK 13
  • Kotlin
  • Spring Cloud
    • Spring Cloud Gateway
    • Spring Cloud Config
    • Spring Cloud Sleuth
    • Spring Cloud OpenFeign
    • Spring Cloud Netflix
      • Eureka
      • Hystrix
      • Ribbon
  • Gradle with Kotlin DSL
  • JUnit
  • Other: Thymeleaf, Bootstrap, Webjars

Diagram of components

-

Config server

Stores configs of all microservices.

Service discovery server

Performs Service registry function. Spring Cloud Netflix Eureka is used which is Client-side service discovery. Each application sends heartbeats to Eureka server after registration.

Items service

This is an example of back-end with REST API implemented with Spring WebFlux. HTTP requests are processed with handler. Also microservice demonstrates example of sending additional metadata.

Items UI

This is an example of front-end which uses Thymeleaf for HTML-pages rendering and Bootstrap CSS framework (plugs in with help of Webjars). Application contains a few examples of interacting with back-end (Items service) by using different API:

You can test all of these approaches by request to http://localhost:8081/example.

You can test Hystrix fallback working by request to http://localhost:8081/hystrix-fallback.

UI gateway

Performs authentication and routing to UI microservices (only Items UI in this project). Routing implemented with Spring Cloud Gateway which settings as well as other settings are stored in YAML-config. Also application contains route to Eureka accessed by https://localhost/eureka. All routes you can see by request to https://localhost/actuator/gateway/routes. Access to login page implements using WebFlux. You can perform authentication with one of hardcoded users. Application passes user's login and roles by adding it to HTTP request headers. You can request to https://localhost/items-ui/greeting to see passed credentials. Sure you can access all other endpoints provided by Items UI. As well as Items UI this application uses Thymeleaf and Bootstrap for UI purposes.

SSL

ui-gateway works on port 443 and is available with HTTPS protocol. SSL certificate was created by using following command:

keytool -genkey -alias test_key -storetype PKCS12 -keyalg RSA -keysize 2048 -keystore keystore.p12 -validity 3650

and with qwerty password.

Distributed tracing

-

This schema is simple, see here for details.

Building

Depending of your OS: gradlew clean build or ./gradlew clean build.

Used Gradle 5 requires at least JDK 8.

Running

Run all microservices in the same order as they are listed. If you are using Intellij IDEA with enabled Run Dashboard you should get something like:

-

microservices-example's People

Contributors

rkudryashov 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.