You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@servicecomb.apache.org by GitBox <gi...@apache.org> on 2018/01/01 14:01:05 UTC

[GitHub] wujimin commented on a change in pull request #468: [SCB-126] Add Consumer side event trigger for collect metrics data

wujimin commented on a change in pull request #468: [SCB-126] Add Consumer side event trigger for collect metrics data
URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/468#discussion_r159156465
 
 

 ##########
 File path: core/src/main/java/io/servicecomb/core/provider/consumer/InvokerUtils.java
 ##########
 @@ -72,16 +76,25 @@ public static Response innerSyncInvoke(Invocation invocation) {
           String.format("invoke failed, %s", invocation.getOperationMeta().getMicroserviceQualifiedName());
       LOGGER.debug(msg, e);
       return Response.createConsumerFail(e);
+    } finally {
+      invocation.triggerFinishedEvent();
     }
   }
 
   public static void reactiveInvoke(Invocation invocation, AsyncResponse asyncResp) {
     try {
+      triggerStartedEvent(invocation);
       ReactiveResponseExecutor respExecutor = new ReactiveResponseExecutor();
       invocation.setResponseExecutor(respExecutor);
 
-      invocation.next(asyncResp);
+      AsyncResponse wrappedAsyncResponse = response -> {
+        invocation.triggerFinishedEvent();
+        asyncResp.handle(response);
+      };
+
+      invocation.next(wrappedAsyncResponse);
 
 Review comment:
   ```
         invocation.next(ar -> {
           ......
           asyncResp.handle(ar);
         });
   ```
   your code is no problem
   but maybe this is simpler 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services