Dubbo接口调用的工作总结

了解更多dubbo:http://www.iteye.com/magazines/103#242
=======================

使用开发工具:eclipse

---------------------------------------------
client端配置:
0.引用相关jar包(包括引入服务器端相关方法)
1.客户端配置文件
 <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 --> 
    <dubbo:application name="consumer-of-pear-service-app" />  
       
    <!-- 使用zookeeper注册中心暴露发现服务地址 --> 
    <dubbo:registry protocol="zookeeper" address="10.4.0.53:2181,10.4.0.53:2182,10.4.0.53:2183" />
          
    <!-- 生成远程服务代理,可以和本地bean一样使用PearEquityService -->
    <!-- 作为客户端(请求附加服务系统) -->
    <!-- 查询权益券接口 -->
 <dubbo:reference id="pearService" interface="com.ebiz.manage.point.service.PearService"  timeout="50000" retries="2"/>
 <!-- 预约信息提供接口 -->
 <dubbo:reference id="ebizPearAppointmentService" interface="com.ebiz.manage.point.service.EbizPearAppointmentService"  timeout="50000" retries="2"/> 

2.新建类DubboPearClient
  if(null == context ){
                    String path = props.getVal("DUBBO_SYS_CONFIG_FILE_DIR");
                    logger.info("Dubbo配置文件路径:" + path);
                    context = new ClassPathXmlApplicationContext(new String[] {path});
                    context.start();
                }

 2.1  props代指config.properties
     DUBBO_SYS_CONFIG_FILE_DIR=file:E:/liangSha/渤海NewSVN/www_code/01源码/01Trunk/DEV/pear/WebRoot/WEB-INF/dubboPearClient.xml

3.新建DubboInitServlet
  dubboPearClient = (DubboPearClient) SpringContext.getBean("dubboPearClient");
4.配置完成   访问方法:
PearService pearService=super.getPearService();

    /***
     * 调权益查询接口
     * @return
     */
    protected PearService getPearService() {
     PearService pearService = null;
        try {
            DubboPearClient dubboPearClient = new DubboPearClient();
            pearService = (PearService) dubboPearClient.singleton().getBean("pearService");
        }
        catch (Exception e) {
            logger.info("连接dubbo服务器异常:",e);
        }
        return pearService;
    }


=======================
server服务器端配置
1.jar包引入
2.配置服务器端配置文件
  <dubbo:service  interface="com.ebiz.pear.dubbo.service.PearExchangeMsgService"  ref="PearExchangeMsgService" timeout="50000" retries="2"/>
   <bean id="PearExchangeMsgService" class="com.ebiz.pear.dubbo.service.impl.PearExchangeMsgServiceImpl"></bean>
3.配置完成 PearExchangeMsgService 方法编写
  解析报文,返回报文 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值