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 方法编写
  解析报文,返回报文 

 

 

 

你可能感兴趣的:(eclipse dubbo)