GithubHelp home page GithubHelp logo

k1729p / study10 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 226 KB

Batchfile 17.29% Java 58.17% HTML 24.54%
circuit-breaker eureka-server eureka-service-discovery java load-balancing mock-mvc resilience4j resttemplate spring-cloud-netflix springboot

study10's Introduction

Study10 README Contents


Consumer ● Producer ● Registration

The microservice registration and discovery are done with the Eureka Service Discovery server.
The Eureka server uses a Resilience4J circuit breaker.

The sections of this project:

  1. Starting SpringBoot Servers
  2. Web Browser Client
  3. Curl Client
  4. Scenario with Fallback

Java source code. Packages in modules 'common', 'producer', 'consumer', and 'registration':

module 'common' application sources: kp.common
module 'producer' application sources: kp.producer
module 'consumer' application sources: kp.consumer
module 'registration' application sources: kp.registration


Java API Documentation


❶ Starting SpringBoot Servers

Action:

1. With batch file '01 MVN clean install.bat' build servers.
2. With batch file '02 run registration server.bat' start the Eureka registration server.
3. With batch file '03 run producer server.bat' start the producer-service server.
It registers the 1st instance of producer-service.
4. With batch file '04 run producer server (9091).bat' start the alternative producer-service server on port 9091.
It registers the 2nd instance of producer-service.
5. With batch file '05 run consumer server.bat' start the consumer-service server.

Endpoints
producer-service on port 8081 http://localhost:8081/content
producer-service on port 9091 http://localhost:9091/content
consumer-service http://localhost:8082/content
Eureka Dashboard http://localhost:8761/
Eureka Configuration
producer server application.yml
consumer server application.yml
registration server application.yml

1.1. In the ConsumerApplication the web client 'RestTemplate' is configured to use a 'LoadBalancerClient'.

1.2. The screenshots from the Eureka Dashboard.


Screenshot fragment from the Eureka Dashboard home


Screenshot fragment from the Eureka Dashboard 'registered leases' tab

1.3. The registration server console log screenshot.

1.4. The Eureka server endpoint with the list of registered applications: http://localhost:8761/eureka/apps/.

Back to the top of the page


❷ Web Browser Client

Action:

1. In the web browser call consumer-service two times. Link http://localhost:8082/content.

2.1. Controllers.

The consumer-service controller GET method: kp.consumer.controller.ConsumerController::getContent.

The kp.consumer.service.ConsumerService with web client RestTemplate and CircuitBreaker for fallbacks.

The consumer-service service method: kp.consumer.service.ConsumerService::getContent.

The producer-service controller GET method: kp.producer.controller.ProducerController::getContent.

2.2. Calling the consumer-service two times returns the same result in the web browser.

The result from the consumer-service

The consumer-service was called two times.

console log from the consumer-service server.

On the 1st call, the consumer-service responded with the content from the producer-service on port 9091.

console log from the producer-service server on port 9091.

On the 2nd call, the consumer-service responded with the content from the producer-service on port 8081.

console log from the producer-service server on port 8081.

It is the round-robin load-balancing algorithm.

Back to the top of the page


❸ Curl Client

Action:

1. Execute the batch file 06 CURL read.bat.

3.1. The screenshot of the console log from the run of the batch file "06 CURL read.bat".

Back to the top of the page


❹ Scenario with Fallback

Action:

1. Start the Eureka registration server.
2. Start producer-service server on default port 8081.
3. Start consumer-service server.
4. Execute "06 CURL read.bat".
5. Kill the producer-service on default port 8081.
6. Start producer-service' server on alternative port 9091.
7. Execute "06 CURL read.bat".

4.1. The consumer-service server switches to the next available producer-service server.

4.2. For the absent producer-service there is a response "fallback" from the Resilience4J fallback method.


Console log from the consumer-service with the responses: normal and fallback.

Back to the top of the page


study10's People

Contributors

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