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

溫馨提示×

溫馨提示×

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

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

怎么實現Spring Cloud的斷路器監控

發布時間:2021-11-15 16:32:49 來源:億速云 閱讀:122 作者:iii 欄目:大數據

本篇內容介紹了“怎么實現Spring Cloud的斷路器監控”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

一、準備工作

啟動以前的項目 erurekaserver,config-server,eurekaclient1

二、修改項目service-ribbon

1、修改ServiceRibbonApplication.java

package wg;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.hystrix.EnableHystrix;
import org.springframework.cloud.netflix.hystrix.dashboard.EnableHystrixDashboard;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

@SpringBootApplication
@EnableEurekaClient
@EnableDiscoveryClient
@EnableHystrix
@EnableCircuitBreaker
@EnableHystrixDashboard
public class ServiceRibbonApplication {
	public static void main(String[] args) {
        SpringApplication.run( ServiceRibbonApplication.class, args );
    }

    @Bean
    @LoadBalanced
    RestTemplate restTemplate() {
        return new RestTemplate();
    }
    
    @Bean
    public ServletRegistrationBean getServlet(){

       HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();

       ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);

       registrationBean.setLoadOnStartup(1);

       registrationBean.addUrlMappings("/actuator/hystrix.stream");

       registrationBean.setName("HystrixMetricsStreamServlet");


       return registrationBean;
    }
}

2、修改pom.xml

<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">
  <modelVersion>4.0.0</modelVersion>

  <groupId>wg</groupId>
  <artifactId>service-ribbon</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>service-ribbon</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <spring-cloud.version>Greenwich.RELEASE</spring-cloud.version>
    <java.version>1.8</java.version>
  </properties>

  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.1.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
  </parent>

  <dependencies>
  	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-zipkin</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-netflix-hystrix</artifactId>
	</dependency>
	<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
    </dependency>
	<dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-dependencies</artifactId>
        <version>${spring-cloud.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>

3、啟動項目,訪問:http://localhost:8764/hello

怎么實現Spring Cloud的斷路器監控

4、訪問:http://localhost:8764/hystrix

輸入:怎么實現Spring Cloud的斷路器監控

確定,留著這個頁面打開狀態。

怎么實現Spring Cloud的斷路器監控

5、 訪問:http://localhost:8764/hello,回來查看監控頁:

怎么實現Spring Cloud的斷路器監控

6、關閉 eurekaclient1  ,訪問 :http://localhost:8764/hello

怎么實現Spring Cloud的斷路器監控

查看監控頁面:

怎么實現Spring Cloud的斷路器監控

“怎么實現Spring Cloud的斷路器監控”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

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

AI

济南市| 浦东新区| 绥芬河市| 西宁市| 漳浦县| 威远县| 洛川县| 温泉县| 玉门市| 玛纳斯县| 达拉特旗| 新宁县| 阳谷县| 阜阳市| 娱乐| 自贡市| 长葛市| 肥东县| 手游| 独山县| 安达市| 余庆县| 萨迦县| 土默特右旗| 天津市| 兰西县| 海城市| 漠河县| 朔州市| 黑山县| 台南市| 建水县| 九龙县| 博白县| 延津县| 瑞安市| 河北区| 瑞丽市| 大悟县| 五台县| 石棉县|