apache / apache/dubbo-samples

Why the sample 'dubbo-samples-notify' need interface Notify.class

Open
#351 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.4k
Forks
2k
PR merge metrics
No merged PRs in 30d

Description

why we need interface Notify for NotifyImpl? In the sample inject bean is NotifyImpl ,so what Notify need for?
It's seem that dubbo need Notify for each method. but different method has their own params。
So I definition the notify interface like this:
```
public interface Notify {
void onReturn(DubboResult result, T t);

void onThrow(Throwable ex, T t);

}
```
implements like this:

```
public class AllotNotify implements Notify{
public Map ret = Maps.newConcurrentMap();

@Override
public void onReturn(DubboResult result, FulfillmentContext context) {
log.info("[AllotNotify] onReturn storeId:{} result:{}",context.getErpStoreId(),result.getResult());
ret.remove(context.getErpStoreId());

}

@Override
public void onThrow(Throwable ex, FulfillmentContext context) {
log.error("[AllotNotify] onThrow storeId:"+context.getErpStoreId(),ex);

}

}
```

then spring throw exception :
```
Caused by: java.lang.IllegalStateException: java.lang.IllegalStateException:Not unique method for method name(onReturn) in class(rpc.notify.AllotNotify), find 2 methods.
```

in `ReflectUtils.findMethodByMethodSignature` clazz.getMethods it has double methods for eatch methods

![image](https://user-images.githubusercontent.com/5241928/127132184-32f921f4-990e-4908-bdfe-32e68f36a1fa.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.