SpringCloud分布式微服务b2b2c电子商务中​怎么用turbine+hystrix-dashboard监听两个消费者服务

技术SpringCloud分布式微服务b2b2c电子商务中​怎么用turbine+hystrix-dashboard监听两个消费者服务这篇文章主要介绍SpringCloud分布式微服务b2b2c电子商务中怎么用turbi

这篇文章主要介绍SpringCloud分布式微服务b2b2c电子商务中怎么用涡轮迟滞线-仪表板监听两个消费者服务,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!

怎么用涡轮迟滞线-仪表板监听两个消费者服务

一、监听模块微服务-消费者-电影feign与海斯特里克斯断路器的运行状况

二、监听模块微服务-消费者-电影-带滞后功能的色带一断路器的运行状况

2.1、创建模块微服务-消费者-电影-带滞后功能的色带一

SpringCloud分布式微服务b2b2c电子商务中怎么用turbine+hystrix-dashboard监听两个消费者服务

2.2、pom.xml文件

?xmlversion='1.0 '编码='UTF-8 '?

项目xmlns=' http://aven。阿帕奇。org/POM/4。0 .0 '

xmlns : xsi=' http://www。w3。org/2001/XMLSchema-instance '

xsi :架构位置=' http://aven。阿帕奇。org/POM/4。0 .0http://aven。阿帕奇。org/xsd/maven-4。0 .0 .xsd '

父母

artifactIdmicroservice-spring-cloud/artifactId

groupIdcom.jacky/groupId

1.0版-快照/版本

/家长

模型版本4 .0 .0/模型版本

人工智能微服务-消费者-电影-带滞后功能区1/人工智能

包装罐/包装

性能

项目。建造。sourceencodingutf-8/项目。建造。源编码

项目。报道。outputen coding TF-8/项目。报道。输出编码

java.version1.8/java.version

/properties

属国

属国

groupIdorg.springframework.boot/groupId

n

bsp;         <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监听两个消费者服务”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注行业资讯频道!

内容来源网络,如有侵权,联系删除,本文地址:https://www.230890.com/zhan/104207.html

(0)

相关推荐

  • 火线字母,请问插头上的l。n那个是火线

    技术火线字母,请问插头上的l。n那个是火线按我国现行标准,GB2681中第3条依导线颜色标志电路时,一般应该是相线-A相黄色,B相绿色,C相红色。零线-淡蓝色。地线是黄绿相间。如果是三相插座,左边是零线,中间(上面)是地

    生活 2021年10月23日
  • 抖音播放量突然被限流降权是什么原因

    技术抖音播放量突然被限流降权是什么原因 抖音播放量突然被限流降权是什么原因抖音播放量突然被限流降权是什么原因本来发布的视频播放量都挺稳定的,但突然有一天发布的视频播放量急降,这个情况相信不少用户也遇到过

    礼包 2021年11月27日
  • 怎么解决php输出图片并显示中文乱码问题

    技术怎么解决php输出图片并显示中文乱码问题这篇文章主要讲解了“怎么解决php输出图片并显示中文乱码问题”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“怎么解决php输出图

    攻略 2021年10月25日
  • 如何掌握Quartz.net分布式定时任务的姿势

    技术如何掌握Quartz.net分布式定时任务的姿势这篇文章给大家介绍如何掌握Quartz.net分布式定时任务的姿势,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。引言长话短说,今天聊一聊分布式定时

    攻略 2021年11月18日
  • Git提交规范是什么

    技术Git提交规范是什么本篇内容介绍了“Git提交规范是什么”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!一、为什么需要

    攻略 2021年11月11日
  • 如何解决甲骨文中的SVR4错误问题

    技术oracle出现SVR4 Error报错问题怎么解决这篇文章主要讲解了“oracle出现SVR4 Error报错问题怎么解决”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学

    攻略 2021年12月22日