You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/07/27 09:39:49 UTC

[GitHub] [dubbo-samples] zemochen opened a new issue #351: Why the sample 'dubbo-samples-notify' need interface Notify.class

zemochen opened a new issue #351:
URL: https://github.com/apache/dubbo-samples/issues/351


   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<T> {
       void onReturn(DubboResult result, T t);
   
       void onThrow(Throwable ex, T t);
   
   
   }
   ```
   implements like this:
   
   ```
   public class AllotNotify implements Notify<FulfillmentContext>{
       public Map<Long, Object> 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)
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo-samples] daidai21 commented on issue #351: Why the sample 'dubbo-samples-notify' need interface Notify.class

Posted by GitBox <gi...@apache.org>.
daidai21 commented on issue #351:
URL: https://github.com/apache/dubbo-samples/issues/351#issuecomment-1013070251


   Hi, I meet the same problem. how do you solve this problem? @zemochen 
   
   


-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org