作者 朱兆平

将feign拦截器设置成两部分,新舱单接口拦截器和基本拦截器

package com.sy.feign;
import feign.Retryer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class BaseInterceptor {
/**
* 设置feign重试次数
* @return
*/
@Bean
public Retryer feignRetryer() {
// 设置最大重试次数为3次
return new Retryer.Default(1000, 5000, 3);
}
}
... ...
... ... @@ -13,17 +13,6 @@ import javax.servlet.http.HttpServletRequest;
@Configuration
public class NmmsInterceptor {
/**
* 设置feign重试次数
* @return
*/
@Bean
public Retryer feignRetryer() {
// 设置最大重试次数为3次
return new Retryer.Default(1000, 5000, 3);
}
@Bean
public RequestInterceptor requestInterceptor() {
return new RequestInterceptor() {
... ...
package com.sy.service.feigin;
import com.sy.feign.BaseInterceptor;
import com.sy.feign.NmmsInterceptor;
import com.sy.model.LockFeignResponse;
import com.sy.model.NoticeLock;
import com.sy.response.ResultJson;
... ... @@ -13,7 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
* 金二报文发送接口
* @author mrz
*/
@FeignClient(name = "SEND-IBMMQ-SERVIER",fallbackFactory = G2X81FeignFallBackFactory.class)
@FeignClient(name = "SEND-IBMMQ-SERVIER",fallbackFactory = G2X81FeignFallBackFactory.class,configuration = BaseInterceptor.class)
public interface G2X81FeignService {
@PostMapping("/ibm/mq/sendMsg")
... ...