Dubbo: CompletableFuture<T> support for GenericService.

Created on 7 Jan 2019  ·  9Comments  ·  Source: apache/dubbo

泛化调用中

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

}

这里可不可以异步调用返回个Future。我的工具实现会有多个 ReferenceConfig 缓存,我可以单独再用一个线程池来作为 $invoke 的执行上下文。但每个 ReferenceConfig 好像都有一组线程来维持,这个本身能不能异步调用?

Most helpful comment

应该是可以的,不过我需要验证一下效果,但是需要改造一下GenericService接口。
可能将来会长这样:

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

    CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;
}

All 9 comments

应该是可以的,不过我需要验证一下效果,但是需要改造一下GenericService接口。
可能将来会长这样:

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

    CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;
}

OK,期待...

I was suddenly more curious at the time that the GenericService did not implement asynchronous calls? Haha

应该是可以的,不过我需要验证一下效果,但是需要改造一下GenericService接口。
可能将来会长这样:

public interface GenericService {

    Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

    CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;
}

oninvoke、onreturn、onthrow 也要支持下 GenericService
例如下面判断:
final Method onInvokeMethod = (Method) StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_METHOD_KEY));
final Object onInvokeInst = StaticContext.getSystemContext().get(StaticContext.getKey(invoker.getUrl(), invocation.getMethodName(), Constants.ON_INVOKE_INSTANCE_KEY));

public interface GenericService {

Object $invoke(String method, String[] parameterTypes, Object[] args) throws GenericException;

CompletableFuture<Object> $invokeAsync(String method, String[] parameterTypes, Object[] args) throws GenericException;

}

Is there any progress on this feature?

@chickenlj
Hi, I am very sorry that I have been procrastinating for a long time.
I will try to solve this problem this week. If it's more complicated, I'll discuss a scenario on the mailing list.

@carryxyh No hurry, if you don't get enough time maybe I can give it a try. Just make sure we don't spend too much time repeating this issue.

Simple pr for this issue:
https://github.com/apache/incubator-dubbo/pull/3637

Would u pls have a review?

I am on it.

Was this page helpful?
0 / 5 - 0 ratings