日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

feign.RetryableException null executing post

發布時間:2024/9/19 编程问答 120 豆豆
生活随笔 收集整理的這篇文章主要介紹了 feign.RetryableException null executing post 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

feign調用遇到的問題,該文為轉載,記錄一下

feign.RetryableException: null executing GET http://****/cr**t/e**/cre****ount/2**8060 at feign.FeignException.errorExecuting(FeignException.java:132) at feign.SynchronousMethodHandler.executeAndDecode(SynchronousMethodHandler.java:113) at feign.SynchronousMethodHandler.invoke(SynchronousMethodHandler.java:78) at feign.ReflectiveFeign$FeignInvocationHandler.invoke(ReflectiveFeign.java:103) at com.sun.proxy.$Proxy189.getCustomerCredit4Ebs(Unknown Source) at com.crpt.biz.service.impl.ebs.QueryCustomeCreditService.execute(QueryCustomeCreditService.java:56) at com.crpt.biz.service.impl.ebs.QueryCustomeCreditService.execute(QueryCustomeCreditService.java:23) at com.crpt.biz.ebs.webservice.CrptEBSService.request(CrptEBSService.java:92) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.cxf.service.invoker.AbstractInvoker.performInvocation(AbstractInvoker.java:179) at org.apache.cxf.jaxws.JAXWSMethodInvoker.performInvocation(JAXWSMethodInvoker.java:66) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:96) at org.apache.cxf.jaxws.AbstractJAXWSMethodInvoker.invoke(AbstractJAXWSMethodInvoker.java:232) at org.apache.cxf.jaxws.JAXWSMethodInvoker.invoke(JAXWSMethodInvoker.java:85) at org.apache.cxf.service.invoker.AbstractInvoker.invoke(AbstractInvoker.java:74) at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266)

CXF能夠正常接入數據,但是接入后調用微服務內部的feign報錯

原因webservice客戶端請求時,攜帶了這個header信息:transfer-encoding:chunked

而springcloud會把請求過來的http header信息轉嫁給下一次發生調用的feign中,源碼詳見feign.SynchronousMethodHandler#targetRequest

這樣就需要我們定值一個RequestInterceptor去簡化一下header

@Component @Slf4j public class FeignRequestInterceptor implements RequestInterceptor { final static String TRANSFER_ENCODING = "transfer-encoding"; @Override public void apply(RequestTemplate requestTemplate) {ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();if(attributes==null)return ;HttpServletRequest request= attributes.getRequest();Enumeration<String> headerNames = request.getHeaderNames();if (headerNames != null) {while (headerNames.hasMoreElements()) {String name = headerNames.nextElement();String values = request.getHeader(name);if(isOverLapHeader(requestTemplate,name))requestTemplate.header(name, values);}} } //是否允許覆蓋requestTemplate中的header private boolean isOverLapHeader(RequestTemplate requestTemplate,String headerName) {Map<String, Collection<String>> headers= requestTemplate.headers();if(headers==null){return true;}if (TRANSFER_ENCODING.equalsIgnoreCase(headerName)) {return false;}return true;

}

這樣內部的feign調用時就不會有問題了

原文鏈接:https://juejin.cn/post/6964174845051404302#comment

總結

以上是生活随笔為你收集整理的feign.RetryableException null executing post的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。