提交 2f685ed8 编写于 作者: C chao.liuc

DUBBO-354 API方式指定方法调用为异步

git-svn-id: http://code.alibabatech.com/svn/dubbo/trunk@1622 1a56cb94-b969-4eaa-88fa-be21384802f2
上级 301f461f
......@@ -535,6 +535,7 @@ public class Constants {
public static class Attachments {
public static final String IS_ASYNC_KEY = "attachments.async";
public static final String IS_ONEWAY_KEY = "attachments.oneway";
public static final String INVOCATIONID_KEY = "attachments.invocation.id";
}
......
......@@ -42,9 +42,10 @@ public class DemoAction {
System.out.println("async call ret :" + f.get());
RpcContext.getContext().onewayCall(new Callable<String>() {
public String call() throws Exception {
return demoService.sayHello("oneway call request");
RpcContext.getContext().asyncCall(new Runnable() {
public void run() {
demoService.sayHello("oneway call request");
demoService.sayHello("oneway call request");
}
});
......
......@@ -573,11 +573,11 @@ public class RpcContext {
* oneway调用,只发送请求,不接收返回结果.
* @param callable
*/
public void onewayCall(Callable<?> callable) {
public void asyncCall(Runnable runable) {
try {
setAttachment(Constants.Attachments.IS_ONEWAY_KEY, Boolean.TRUE.toString());
callable.call();
} catch (Exception e) {
runable.run();
} catch (Throwable e) {
//FIXME 异常是否应该放在future中?
throw new RpcException("oneway call error ." + e.getMessage(), e);
} finally {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册