SpringCloudAlibaba 개발 환경의 퓨즈 Sentinel 구축
구축 공급 자 와 소비자
SpringCloudAlibaba 개발 환경 을 구축 하 는 서비스 소비자 와 공급 자 는 feign 을 통 해 통신 합 니 다.
소비자 들 사이 에 퓨즈 를 세우다
우리 프로그램의 서비스 제공 자가 고장 이 났 을 때 소비자 중의 퓨즈 는 이번 프로그램의 대상 이 요청 한 응답 을 제때에 끝내 고 servlet 용기 의 스 레 드 를 방출 하여 servlet 스 레 드 가 소모 되 지 않도록 합 니 다. 즉, 전체 마이크로 서비스 가 마비 되 는 것 입 니 다. 즉, 눈사태 가 발생 하 는 것 입 니 다.
sentinel 의존 가입
4.0.0
bygones-consumer
1.0.0-SNAPSHOT
jar
com.bygones
bygones-dependencies
1.0.0-SNAPSHOST
../bygones-dependencies/pom.xml
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-actuator
com.alibaba.cloud
spring-cloud-starter-alibaba-nacos-discovery
org.springframework.cloud
spring-cloud-starter-openfeign
com.alibaba.cloud
spring-cloud-starter-alibaba-sentinel
application. yml 에서 sentinel 서 비 스 를 엽 니 다.
spring:
application:
name: consumer
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
server:
port: 8081
feign:
sentinel:
enabled: true # sentinel
녹 아내 릴 때 실행 하 는 방법 만 들 기
import com.bygones.consumer.service.AccessProviderService;
import org.springframework.stereotype.Service;
/**
*
*
* feign , servlet
*/
@Service
public class AccessProviderServiceFallback implements AccessProviderService {
@Override
public String consumerAccessProvider(String message) {
return " ";
}
}
feign 인터페이스 에서 녹 아내 릴 때 실행 되 는 함 수 를 호출 합 니 다.
import com.bygones.consumer.service.impl.AccessProviderServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
/**
* feign
* (1) FeignClient
* (2) mapping
*/
@FeignClient(value = "provider", fallback = AccessProviderServiceFallback.class) // value application.name, fallback
public interface AccessProviderService {
@GetMapping("consumer-access-provider/{message}") // mapping , mapping
String consumerAccessProvider(@PathVariable("message") String message); //
}
프로젝트 개발 자 는 sentinel dashboard 모니터링 을 통 해 녹 습 니 다.
위의 설정 을 통 해
sentinel 대시 보드 환경 구축 (Windows)
springcloudaliaba 와 sentinel 버 전 의존 관 계 를 명 확 히 합 니 다.
https://github.com/alibaba/spring-cloud-alibaba/wiki/버 전 설명
sentinel 대시 보드 다운로드
sentinel 대시 보드 다운로드
sentinel 대시 보드 다운로드 주소https://github.com/alibaba/Sentinel/releases/tag/1.7.1
sentinel 대시 보드 시작
sentinel dashboard 는 표준 Springboot 프로젝트 입 니 다.
시작 명령
java -Dserver.port=8090 -Dcsp.sentinel.dashboard.server=localhost:8090 -Dproject.name=sentinel-dashboard -jar sentinel-dashboard-1.7.1.jar
sentinel 대시 보드 방문
http://localhost:8090/ 포트 는 시작 입 니 다. 설정 한 포트 사용자 이름 / 비밀번호 sentinel / sentinel 입 니 다.
소비자 통합 sentinel dashboard
프로필 application. yml 에서 소비 자 를 sentinel dashboard 에 등록 합 니 다 spring. cloud. sentinel. transport. dashboard
spring:
application:
name: consumer
cloud:
nacos:
discovery:
server-addr: 127.0.0.1:8848
sentinel:
transport:
dashboard: localhost:8090 # sentinel dashboard
server:
port: 8081
feign:
sentinel:
enabled: true # sentinel
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
[Spring Cloud] LoadBancer-01discoveryservice-eureka 라는 프로젝트를 생성한다 3개 항목을 추가한다. 1. DiscoveryserviceEurekaApplication.java 생성된 -application에 @EnableEu...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.