mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-06-24 05:56:38 +00:00
首页微服务集成Sentinel,实现小说服务调用的熔断降级
This commit is contained in:
@ -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>
|
||||
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
||||
}
|
||||
|
@ -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 {
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
spring:
|
||||
profiles:
|
||||
include: [common]
|
||||
|
||||
feign:
|
||||
sentinel:
|
||||
enabled: true
|
||||
|
Reference in New Issue
Block a user