Browse Source

fallback

dev
jianjun 3 years ago
parent
commit
3e8b7cbb0e
  1. 18
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/fallback/CommonGovOrgFeignClientFallBackFactory.java

18
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; package com.epmet.commons.tools.feign.fallback;
import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.exception.ExceptionUtils;
import com.epmet.commons.tools.dto.form.CustomerGridFormDTO;
import com.epmet.commons.tools.feign.CommonGovOrgFeignClient; import com.epmet.commons.tools.feign.CommonGovOrgFeignClient;
import com.epmet.commons.tools.redis.common.bean.GridInfoCache; import feign.hystrix.FallbackFactory;
import com.epmet.commons.tools.utils.ModuleUtils; import lombok.extern.slf4j.Slf4j;
import com.epmet.commons.tools.utils.Result;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
@ -13,12 +11,14 @@ import org.springframework.stereotype.Component;
* @DateTime 2022/3/17 1:46 下午 * @DateTime 2022/3/17 1:46 下午
* @DESC * @DESC
*/ */
@Slf4j
@Component @Component
public class CommonGovOrgFeignClientFallBackFactory implements CommonGovOrgFeignClient { public class CommonGovOrgFeignClientFallBackFactory implements FallbackFactory<CommonGovOrgFeignClient> {
private CommonOrgFeignClientFallback fallback = new CommonOrgFeignClientFallback();
@Override @Override
public Result<GridInfoCache> getGridInfo(CustomerGridFormDTO customerGridFormDTO) { public CommonGovOrgFeignClient create(Throwable cause) {
return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getGridInfo", customerGridFormDTO); log.error(String.format("FeignClient调用发生异常,异常信息:%s", ExceptionUtils.getThrowableErrorStackTrace(cause)));
return fallback;
} }
} }

Loading…
Cancel
Save