Recently, I am thinking of making the whole invoker chain inside Dubbo 
asynchronous, event-driven. And I believe that `Filter` can be changed to 
better adapt to the new model.

Before 2.7.0, you can find the definition of Filter was completely synchronous:

```java
public interface Filter {
    Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
       // before
        Result result = invoker.invoke(invocation);
       // after
      return result;
    }
}
```

In 2.7.0, a callback `onResponse` was added to allow users to handle the async 
value when result returns.

```java
public interface Filter {
   Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException 
{
   }

   void onResponse(Result result, Invoker<?> invoker, Invocation invocation) {
        // biz return
    }
}
```

Now, how about the following definition, totally asynchronous and event-driven?

```java
public interface Filter {
   void onSend(Invocation invocation) {
     // before invoke, throw exception to terminate 
    }

   void onResponse(Result result, Invoker<?> invoker, Invocation invocation) {
        // biz return successfully
    }

   void onError(Throwable e) throws RpcException{
        // biz throw exception
    }
}
```

[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/3585 ]
This message was relayed via gitbox.apache.org for 
[email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to