官网:http://dubbo.io/
1.xml配置
(1)生产者:(下面该配置既是生产者也是消费者)
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean class="com.te.service.wfr.api.weApiApplicationContext" />
<dubbo:application name="项目名字" organization="dubbox"/>
<dubbo:registry address="${dubbo.registry.address}" />
<dubbo:protocol name="dubbo" port="${dubbo.protocol.port}" />
<!-- 扫描注解包路径,多个包用逗号分隔,不填pacakge表示扫描当前ApplicationContext中所有的类 -->
<dubbo:annotation package="包名" />
<dubbo:service interface="com.xxx.service.xxx.query.xxxService" ref="xxxServiceImpl" filter="Profiling">
<dubbo:method name="queryGoodsList">
<dubbo:argument index="1"/>
</dubbo:method>
<dubbo:method name="queryFavoriteGoodsInfoList"/>
<dubbo:method name="queryMallRecGoodsInfo"/>
</dubbo:service>
<!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
<dubbo:reference id="xxxQueryService" interface="com.xxx.service.xxx.query.xxxQueryService" check="false">
</dubbo:reference>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean class="x.x.x.xxApplicationContext" />
<dubbo:application name="项目名字" organization="dubbox"/>
<!-- dubbo 注册中心的地址 -->
<dubbo:registry address="${address}" />
<!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
<dubbo:reference id="userService" interface="x.x.x.userService" check="false">
</dubbo:reference>
</beans>
telnet localhost 20880(provider dubbo server port)
正常情况下,进入telnet窗口,键入回车进入dubbo命令模式。
ls 查看提供的服务
invoke x.x.x..userService.getUserInfo({"userId":"10000"})看返回结果