首页 > 其他 > 详细

淘宝SOA框架dubbo学习(6)--回声测试

时间:2015-02-12 12:37:39      阅读:348      评论:0      收藏:0      [点我收藏+]

由于用例比较简单,直接上代码吧!

import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.dubbo.demo.DemoService;
import com.alibaba.dubbo.rpc.service.EchoService;

public class Consumer {

    /**
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                new String[] { "classpath:consumer.xml" });
        context.start();

        // 回声测试
        DemoService demoService = (DemoService) context.getBean("demoService");
        for (int i = 0; i < 10; i++) {
            EchoService echoService = (EchoService) demoService; // 强制转型为EchoService

            String status = (String) echoService.$echo("OK=" + i); // 回声测试可用性

            System.out.println(status);
        }

    }
}


客户端控制台返回值:

OK=0
OK=1
OK=2
OK=3
OK=4
OK=5
OK=6
OK=7
OK=8
OK=9


淘宝SOA框架dubbo学习(6)--回声测试

原文:http://my.oschina.net/hanshubo/blog/377974

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!