事件通知

    服务提供者与消费者共享服务接口

    服务提供者实现

    1. class NormalDemoService implements IDemoService {
    2. return new Person(id, "charles`son", 4);
    3. }
    4. }

    服务提供者配置

    服务消费者 Callback 接口

    1. public void onreturn(Person msg, Integer id);
    2. public void onthrow(Throwable ex, Integer id);
    3. }

    服务消费者 Callback 实现

    服务消费者 Callback 配置

    1. <bean id ="demoCallback" class = "org.apache.dubbo.callback.implicit.NofifyImpl" />
    2. <dubbo:method name="get" async="true" onreturn = "demoCallback.onreturn" onthrow="demoCallback.onthrow" />
    3. </dubbo:reference>
    • 异步回调模式:async=true onreturn="xxx"
    • 同步回调模式:async=false onreturn="xxx"
    • 异步无回调 :async=true
    • 同步无回调 :async=false

    测试代码