Springcloud Spring Boot mybatis distributed micro-service Cloud Architecture-docker-hystrix-dashboard-turbine (ix)

Source: Internet
Author: User

Brief introduction

One of the main advantages of Hystrix is that it collects a set of indicators on each hystrixcommand. The Hystrix dashboard shows the health of each circuit breaker in an effective manner, through Hystrix dashboard we can visually see whether the circuit breakers of each Hystrix command are open, request response time, request failure rate, request timeout number, etc. But using only Hystrix dashboard, you can only see the service information in a single app, which is obviously not enough. We need a tool that allows us to summarize data from multiple services in the system and display it on Hystrix Dashboard, a tool that is turbine, which we'll discuss how to monitor two consumer services with Turbine+hystrix-dashboard

One, the monitoring module Microservice-consumer-movie-feign-with-hystrix Circuit Breaker's operation condition

Http://www.cnblogs.com/520playboy/p/8066618.html

Second, the monitor module microservice-consumer-movie-ribbon-with-hystrix1 circuit Breaker's operation condition

2.1. Create Module MICROSERVICE-CONSUMER-MOVIE-RIBBON-WITH-HYSTRIX1

The project structure is as follows:

2.2. pom.xml File

<?xml version= "1.0" encoding= "UTF-8"? ><project xmlns= "http://maven.apache.org/POM/4.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" > <parent> <artifact Id>microservice-spring-cloud</artifactid> <groupId>com.jacky</groupId> <version>1 .0-snapshot</version> </parent> <modelVersion>4.0.0</modelVersion> <artifactid>mic Roservice-consumer-movie-ribbon-with-hystrix1</artifactid> <packaging>jar</packaging> < Properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.re Porting.outputencoding>utf-8</project.reporting.outputencoding> <java.version>1.8</ java.version> </properties> <dependencies> <dependency> <groupid>org.s Pringframework.boot</groupid> <artifactId>spring-boot-starter-web</artifactId> </de      Pendency> <dependency>      <groupId>org.springframework.cloud</groupId> <artifactid>spring-cloud-starter-eureka&lt ;/artifactid> </dependency> <dependency> <groupid>org.springframework.boot&         Lt;/groupid> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId> spring-cloud-starter-hystrix</artifactid> </dependency> <dependency> <groupi         D>org.springframework.cloud</groupid> <artifactId>spring-cloud-starter-zipkin</artifactId>                </dependency> </dependencies> <build> <plugins> <plugin> <groupId>com.spotify</groupId> <artifactid>docker-maven-plugin</artifactid > <Executions> <!--setting up mirroring when executing maven install-<execution>                        <id>build-image</id> <phase>install</phase>                    <goals> <goal>build</goal> </goals> </execution> </executions> <configuration> &lt ;! --Installed Docker host, and opened API remote interface settings--<dockerhost>http://192.168.6.130:5678</dockerhost><pushImage>true</pushImage><!--Setting up an upload image to a private warehouse requires Docker settings specify the private warehouse address--<!--mirror name--< Imagename>${docker.repostory}/${docker.image.prefix}/${project.artifactid}:${project.version}</imagename > <!--the base version of the image--&LT;BASEIMAGE&GT;JAVA:OPENJDK-8-JDK-ALPINE&LT;/BASEIMAGE&G                    T <!--mirroring boot Parameters--<entrypoint>["Java", "-jar", "/${project.build.finalname}.jar"]</entrypoin t> <resources> <resource> &LT;TARGETPA                            Th>/</targetpath> <directory>${project.build.directory}</directory> <include>${project.build.finalName}.jar</include> </resource&gt                    ; </resources> </configuration> </plugin> </plugins> </build></project> 

2.3. configuration file Application.yml

Spring:application:name:microservice-consumer-movie-ribbon-with-hystrix1 sleuth:sampler:percentage:1.0#zipkin: #base-url:http://localhost:7788Server:port:8010eureka:client:healthcheck:enabled:trueserviceUrl:defaultZone:http://Jacky:[email protected]:8761/eureka/,Http://jacky: [Email protected]:8762/eureka/,Http://jacky: [Email protected]:8763/eureka/Instance:prefer-ip-address:trueinstance-ID: ${spring.application.name}:${spring.cloud.client.ipaddress}:${spring.application.instance_id:${ Server.port}}hystrix.command.default. execution.isolation.thread.timeoutinmilliseconds:5000#security: #oauth2: # resource: # Id:microservice-consumer-movie-ribbon-with-hystrix1 # User-info-uri:http://Localhost:9999/uaa/user#prefer-token-info:false

2.4. Entity class User.java

 Packagecom.jacky.cloud.entity;ImportJava.math.BigDecimal; Public classUser {PrivateLong ID; PrivateString username; PrivateString name; PrivateShort Age ; PrivateBigDecimal balance;  PublicLong getId () {return  This. ID; }    Public voidsetId (Long id) { This. ID =ID; }    PublicString GetUserName () {return  This. Username; }    Public voidSetusername (String username) { This. Username =username; }    PublicString GetName () {return  This. Name; }    Public voidsetName (String name) { This. Name =name; }    PublicShort getage () {return  This. Age; }    Public voidSetage (short) { This. Age =Age ; }    PublicBigDecimal getbalance () {return  This. Balance; }    Public voidsetbalance (BigDecimal balance) { This. Balance =balance; } }

2.5. Control Layer Moviecontroller.java

 PackageCom.jacky.cloud.controller;ImportCom.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;Importorg.springframework.beans.factory.annotation.Autowired;Importorg.springframework.web.bind.annotation.GetMapping;Importorg.springframework.web.bind.annotation.PathVariable;ImportOrg.springframework.web.bind.annotation.RestController;Importorg.springframework.web.client.RestTemplate;ImportCom.jacky.cloud.entity.User;ImportCom.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; @RestController Public classMoviecontroller {@AutowiredPrivateresttemplate resttemplate; @GetMapping ("/movie/{id}") @HystrixCommand (Groupkey= "UserGroup1", Commandkey = "FindUserByIdCommand1", commandproperties ={@HystrixProperty (name= "Execution.isolation.thread.timeoutInMilliseconds", value = "1000"), @HystrixProperty (name= "Execution.timeout.enabled", value = "false")},fallbackmethod = "Findbyidfallback")   PublicUser FindByID (@PathVariable Long id) {return  This. Resttemplate.getforobject ("http://microservice-provider-user/simple/" + ID, user.class); }   /*** Fallback method *@paramID *@return     */   Publicuser findbyidfallback (Long ID) {User user=NewUser (); User.setid (5L); returnuser; }}

Source source technical support for complete projects 2147775633

Springcloud Spring Boot mybatis distributed micro-service Cloud Architecture-docker-hystrix-dashboard-turbine (ix)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.