From cd4cddd617a4e0ed4da76e95548881124a70806a Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Thu, 17 Mar 2022 14:38:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=93=88=E5=93=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/feign/fallback/CommonOrgFeignClientFallback.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOrgFeignClientFallback.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOrgFeignClientFallback.java index 1f9ddecf02..c7308d15ab 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOrgFeignClientFallback.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonOrgFeignClientFallback.java @@ -1,6 +1,7 @@ package com.epmet.commons.tools.feign.fallback; import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.dto.form.CustomerGridFormDTO; import com.epmet.commons.tools.feign.CommonGovOrgFeignClient; import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import com.epmet.commons.tools.utils.ModuleUtils; @@ -17,8 +18,8 @@ import org.springframework.stereotype.Component; public class CommonOrgFeignClientFallback implements CommonGovOrgFeignClient { @Override - public Result getGridInfo(String gridId) { - return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridInfo", gridId); + public Result getGridInfo(CustomerGridFormDTO customerGridFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridInfo", customerGridFormDTO); } From 3e8b7cbb0ed820e6bd9e97566af42c36c2579bbd Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 17 Mar 2022 14:54:44 +0800 Subject: [PATCH 2/2] fallback --- ...CommonGovOrgFeignClientFallBackFactory.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovOrgFeignClientFallBackFactory.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovOrgFeignClientFallBackFactory.java index e292d07c69..219d8f38cd 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovOrgFeignClientFallBackFactory.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovOrgFeignClientFallBackFactory.java @@ -1,11 +1,9 @@ package com.epmet.commons.tools.feign.fallback; -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.dto.form.CustomerGridFormDTO; +import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.feign.CommonGovOrgFeignClient; -import com.epmet.commons.tools.redis.common.bean.GridInfoCache; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; /** @@ -13,12 +11,14 @@ import org.springframework.stereotype.Component; * @DateTime 2022/3/17 1:46 下午 * @DESC */ +@Slf4j @Component -public class CommonGovOrgFeignClientFallBackFactory implements CommonGovOrgFeignClient { - +public class CommonGovOrgFeignClientFallBackFactory implements FallbackFactory { + private CommonOrgFeignClientFallback fallback = new CommonOrgFeignClientFallback(); @Override - public Result getGridInfo(CustomerGridFormDTO customerGridFormDTO) { - return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridInfo", customerGridFormDTO); + public CommonGovOrgFeignClient create(Throwable cause) { + log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause))); + return fallback; } }