wujimin commented on issue #2051:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2051#issuecomment-731955112
明白了
基于现有版本,一个可能的快速规避方案如下
你看一下是否ok:
* 继承Invoker定制自己的逻辑
```java
public class MyInvoker extend Invoker {
public static <T> T createProxy(......) {
......
}
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
try {
super.invoke(proxy, method, args);
} catch (Throwable e) {
你们的转换逻辑
这样处理,只搞定了同步调用,如果想异步也搞定,可以分别override syncInvoke和completableFutureInvoke
其中completableFutureInvoke不仅仅需要catch,还需要订阅future的结果做异常转换
}
}
}
```
* 如何使用新invoker
```java
@Configuration
public class ConsumerConfiguration {
@Bean
MyConsumerInterface myConsumerInterface() {
return MyInvoker.createProxy(......);
}
}
```
# 缺点
syncInvoke和completableFutureInvoke是实现级的,不一定稳定,后续如果有变化,你们的代码需要同步跟着变一下
----------------------------------------------------------------
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:
[email protected]