事件通知
服务提供者与消费者共享服务接口
服务提供者实现
class NormalDemoService implements IDemoService {
return new Person(id, "charles`son", 4);
}
}
服务提供者配置
服务消费者 Callback 接口
public void onreturn(Person msg, Integer id);
public void onthrow(Throwable ex, Integer id);
}
服务消费者 Callback 实现
服务消费者 Callback 配置
<bean id ="demoCallback" class = "org.apache.dubbo.callback.implicit.NofifyImpl" />
<dubbo:method name="get" async="true" onreturn = "demoCallback.onreturn" onthrow="demoCallback.onthrow" />
</dubbo:reference>
- 异步回调模式:
async=true onreturn="xxx"
- 同步回调模式:
async=false onreturn="xxx"
- 异步无回调 :
async=true
- 同步无回调 :
async=false
测试代码
-
-