You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2020/12/19 16:19:03 UTC

[GitHub] [servicecomb-java-chassis] issxjl2015 opened a new issue #2152: 写了一个记录三方请求的logFilter,当请求三方接口超时,logFilter无法接收到response,导致三方日志不打印

issxjl2015 opened a new issue #2152:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2152


   背景:
   基于SPI机制,实现了一个记录三方日志的logFilter, 正常请求下,对request和response进行记录。
   
   当超时场景下,response无法收到,框架直接抛出490异常。对于logFilter,少记录了一条超时日志。
   
   看源码,发现可以对FallbackPolicy接口进行扩展实现,重写了record方法(记录日志),同时配置超时的policy。
   
   但是在调试代码的时候,发现POLICYS是BeanHolder注入的,始终无法加载到我设置的超时policy。
   
   问题:
   实现了FallbackPolicy接口后,如何加载超时policy,且在超时情况下,能调用到record方法。求助,谢谢


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] issxjl2015 commented on issue #2152: 写了一个记录三方请求的logFilter,当请求三方接口超时,logFilter无法接收到response,导致三方日志不打印

Posted by GitBox <gi...@apache.org>.
issxjl2015 commented on issue #2152:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2152#issuecomment-750325424


   microservice.yaml中配置上policy以及bean.xml中配置上扫描包,自然就实现了。


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2152: 写了一个记录三方请求的logFilter,当请求三方接口超时,logFilter无法接收到response,导致三方日志不打印

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2152:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2152#issuecomment-748985847


   FallbackPolicy 的实现是 bean, 可以参考其他 java-chassis 的实现, 比如:
   
   ```
   @Component
   public class FromCacheFallbackPolicy implements FallbackPolicy {
     private static final String POLICY_NAME = "fromCache";
   
     private Map<String, Response> cachedResponse = new ConcurrentHashMap<>();
   
     @Override
     public String name() {
       return POLICY_NAME;
     }
   
     @Override
     public Response getFallbackResponse(Invocation invocation, Throwable error) {
       if (cachedResponse.get(invocation.getInvocationQualifiedName()) != null) {
         return cachedResponse.get(invocation.getInvocationQualifiedName());
       } else {
         return Response.succResp(null);
       }
     }
   
     @Override
     public void record(Invocation invocation, Response response, boolean isSuccess) {
       if (isSuccess) {
         cachedResponse.put(invocation.getInvocationQualifiedName(), response);
       }
     }
   }
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] issxjl2015 commented on issue #2152: 写了一个记录三方请求的logFilter,当请求三方接口超时,logFilter无法接收到response,导致三方日志不打印

Posted by GitBox <gi...@apache.org>.
issxjl2015 commented on issue #2152:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2152#issuecomment-749045391


   嗯,我确实也参考了FromCacheFallbackPolicy 的实现,写了自己的策略。
   今天又翻看了一下官方文档,可能还需要在microservice.yaml中加上这个policy,要不然不知道使用什么策略。
   不过还没试过,明天再看看效果。
   `
   servicecomb:
       fallbackpolicy:
         consumer:
           policy: returnnull
   `


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] issxjl2015 closed issue #2152: 写了一个记录三方请求的logFilter,当请求三方接口超时,logFilter无法接收到response,导致三方日志不打印

Posted by GitBox <gi...@apache.org>.
issxjl2015 closed issue #2152:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2152


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org