91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

SpringCloud分布式微服務b2b2c電子商務中?怎么用turbine+hystrix-dashboard監聽兩個消費者服務

發布時間:2021-11-19 11:53:29 來源:億速云 閱讀:186 作者:小新 欄目:軟件技術

這篇文章主要介紹SpringCloud分布式微服務b2b2c電子商務中怎么用turbine+hystrix-dashboard監聽兩個消費者服務,文中介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們一定要看完!

怎么用turbine+hystrix-dashboard監聽兩個消費者服務

一、監聽模塊microservice-consumer-movie-feign-with-hystrix斷路器的運行狀況

二、監聽模塊microservice-consumer-movie-ribbon-with-hystrix1斷路器的運行狀況

2.1、創建模塊microservice-consumer-movie-ribbon-with-hystrix1

SpringCloud分布式微服務b2b2c電子商務中?怎么用turbine+hystrix-dashboard監聽兩個消費者服務

2.2、pom.xml文件

<?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>
        <artifactId>microservice-spring-cloud</artifactId>
        <groupId>com.jacky</groupId>
        <version>1.0-SNAPSHOT</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>
 
    <artifactId>microservice-consumer-movie-ribbon-with-hystrix1</artifactId>
    <packaging>jar</packaging>
 
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>
 
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
 
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka</artifactId>
        </dependency>
 
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
 
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-hystrix</artifactId>
        </dependency>
        <dependency>
            <groupId>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>
                    <!--設置在執行maven 的install時構建鏡像-->
                    <execution>
                        <id>build-image</id>
                        <phase>install</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!--安裝了docker的主機,并且打開了api remote接口設置-->
                    <dockerHost>http://192.168.6.130:5678</dockerHost>
                    <pushImage>true</pushImage><!--設置上傳鏡像到私有倉庫,需要docker設置指定私有倉庫地址-->
                    <!--鏡像名稱-->
                    <imageName>${docker.repostory}/${docker.image.prefix}/${project.artifactId}:${project.version}</imageName>
                    <!--鏡像的基礎版本-->
                    <baseImage>java:openjdk-8-jdk-alpine</baseImage>
                    <!--鏡像啟動參數-->
                    <entryPoint>["java", "-jar", "/${project.build.finalName}.jar"]</entryPoint>
                    <resources>
                        <resource>
                            <targetPath>/</targetPath>
                            <directory>${project.build.directory}</directory>
                            <include>${project.build.finalName}.jar</include>
                        </resource>
                    </resources>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

2.3、配置文件application.yml

spring:
  application:
    name: microservice-consumer-movie-ribbon-with-hystrix1
  sleuth:
    sampler:
      percentage: 1.0
  #zipkin:
    #base-url: http://localhost:7788
server:
  port: 8010
eureka:
  client:
    healthcheck:
      enabled: true
    serviceUrl:
      defaultZone: http://jacky:admin@peer1:8761/eureka/,http://jacky:admin@peer2:8762/eureka/,http://jacky:admin@peer3:8763/eureka/
  instance:
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: 5000
#security:
  #oauth3:
   # resource:
    #  id: microservice-consumer-movie-ribbon-with-hystrix1
     # user-info-uri: http://localhost:9999/uaa/user
      #prefer-token-info: false

2.4、實體類User.java

package com.jacky.cloud.entity;
 
import java.math.BigDecimal;
 
public class User {
  private Long id;
 
  private String username;
 
  private String name;
 
  private Short age;
 
  private BigDecimal balance;
 
  public Long getId() {
    return this.id;
  }
 
  public void setId(Long id) {
    this.id = id;
  }
 
  public String getUsername() {
    return this.username;
  }
 
  public void setUsername(String username) {
    this.username = username;
  }
 
  public String getName() {
    return this.name;
  }
 
  public void setName(String name) {
    this.name = name;
  }
 
  public Short getAge() {
    return this.age;
  }
 
  public void setAge(Short age) {
    this.age = age;
  }
 
  public BigDecimal getBalance() {
    return this.balance;
  }
 
  public void setBalance(BigDecimal balance) {
    this.balance = balance;
  }
 
}

2.5、控制層MovieController.java

package com.jacky.cloud.controller;
 
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.beans.factory.annotation.Autowired;
 
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
 
import com.jacky.cloud.entity.User;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
 
@RestController
public class MovieController {
  @Autowired
  private RestTemplate 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")
  public User findById(@PathVariable Long id) {
    return this.restTemplate.getForObject("http://microservice-provider-user/simple/" + id, User.class);
  }
 
  /**
   * fallback方法
   * @param id
   * @return
     */
  public User findByIdFallback(Long id) {
    User user = new User();
    user.setId(5L);
    return user;
  }
}

以上是“SpringCloud分布式微服務b2b2c電子商務中怎么用turbine+hystrix-dashboard監聽兩個消費者服務”這篇文章的所有內容,感謝各位的閱讀!希望分享的內容對大家有幫助,更多相關知識,歡迎關注億速云行業資訊頻道!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

秦安县| 陇南市| 革吉县| 青冈县| 巴彦淖尔市| 普宁市| 多伦县| 海南省| 宁化县| 梅州市| 通道| 津南区| 焦作市| 九寨沟县| 崇文区| 闵行区| 宿松县| 威远县| 黔江区| 琼海市| 大足县| 会理县| 台前县| 平和县| 长治县| 定州市| 泸州市| 祁门县| 中西区| 广昌县| 衢州市| 张家口市| 曲麻莱县| 琼海市| 梨树县| 盐亭县| 铜山县| 鹤山市| 谢通门县| 神农架林区| 隆林|