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;
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<CommonGovOrgFeignClient> {
private CommonOrgFeignClientFallback fallback = new CommonOrgFeignClientFallback();
@Override
public Result<GridInfoCache> 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;
}
}

Loading…
Cancel
Save