【dubbo】dubbo專案 通過RPC方式呼叫自己應用對外提供的dubbo介面
阿新 • • 發佈:2020-09-07
dubbo專案,從Spring容器中拿一個自己服務提供的dubbo介面直接呼叫:
[不通過註冊中心,效果即自己呼叫自己的一個Bean]
xml配置:
<dubbo:service interface="com.xxx.api.AAAService" ref="aaaService" timeout="5000"/>
<bean name="aaaService" class="com.xxx.api.AAAServiceImpl" />
Java使用:
@Resource
private AAAService aaaService;
aaaService.method1();
====================================================================================================
dubbo專案,從註冊中心通過RPC方式呼叫自己服務提供的dubbo介面:
[通過註冊中心,效果即 自己呼叫別人的dubbo服務一樣]
[區別就在於 下面的 藍色加粗的一行配置]
xml配置:
<dubbo:service interface="com.xxx.api.AAAService" ref="aaaService" timeout="5000"/>
<bean name="aaaService" class="com.xxx.api.AAAServiceImpl" />
<dubbo:reference id="bbbService" interface="com.xxx.api.AAAService" check="false"/>
Java使用:
@Resource
private AAAService bbbService;
bbbService.method1();