首页微服务集成Sentinel,实现小说服务调用的熔断降级

This commit is contained in:
xiongxiaoyang
2020-06-07 16:02:35 +08:00
parent 98b371d348
commit deae12762e
9 changed files with 110 additions and 6 deletions

View File

@ -23,12 +23,12 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-hystrix</artifactId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

View File

@ -1,6 +1,7 @@
package com.java2nb.novel.home.feign;
import com.java2nb.novel.book.api.BookApi;
import com.java2nb.novel.home.feign.fallback.BookFeignFallback;
import org.springframework.cloud.openfeign.FeignClient;
/**
@ -9,7 +10,9 @@ import org.springframework.cloud.openfeign.FeignClient;
* @version 1.0
* @since 2020/5/28
*/
@FeignClient("book-service")
@FeignClient(name = "book-service",fallback = BookFeignFallback.class)
public interface BookFeignClient extends BookApi {
}

View File

@ -0,0 +1,15 @@
package com.java2nb.novel.home.feign.fallback;
import com.java2nb.novel.book.api.fallback.BookApiFallback;
import com.java2nb.novel.home.feign.BookFeignClient;
import org.springframework.stereotype.Service;
/**
* 小说Feign客户端降级处理类(服务消费端,自定义降级处理)
* @author xiongxiaoyang
* @version 1.0
* @since 2020/6/7
*/
@Service
public class BookFeignFallback extends BookApiFallback implements BookFeignClient {
}

View File

@ -1,4 +1,6 @@
spring:
profiles:
include: [common]
feign:
sentinel:
enabled: true