zoukankan      html  css  js  c++  java
  • LR中测试dubbo接口的脚本

    import lrapi.lr;
    import com.alibaba.dubbo.config.ApplicationConfig;
    import com.alibaba.dubbo.config.ReferenceConfig;
    import com.unj.dubbotest.provider.DemoService;

    public class Actions
    {
    private final String ID = "ID";

    //dubbo服务地址
    private final String URL = "dubbo://ip:20880";

    //版本号
    private final String VERSION = "1.0.0";

    //服务名
    private final String SERVICE_NAME = "com.unj.dubbotest.provider.DemoService";

    private Object object;

    public int init() throws Throwable {
    // 当前应用配置
    ApplicationConfig application = new ApplicationConfig();
    application.setName("hehe_consumer");

    // 引用远程服务
    ReferenceConfig reference = new ReferenceConfig();
    reference.setApplication(application);
    reference.setId(ID);
    reference.setVersion(VERSION);

    // dubbo服务名
    reference.setInterface(SERVICE_NAME);

    // dubboip地址
    reference.setUrl(URL);

    // 和本地bean一样使用xxxService
    object = reference.get();
    return 0;
    }


    public int action() throws Throwable {
    DemoService demoService = (DemoService)object;
    String hello = demoService.sayHello("dubboTest");
    System.out.println(hello);
    return 0;
    }


    public int end() throws Throwable {
    return 0;
    }
    }

  • 相关阅读:
    JavaBasics-15-多线程
    4.10 SpringCloud微服务技术栈
    4.3 Linux操作系统_Unix操作系统
    4.2 互联网项目架构演进
    4.1 微服务框架_引言
    4.6 Redis
    SpringBoot
    docker-dockerfile实战构建文件
    docker 安装私有仓库 registry(离线)
    基础K8S搭建(20209.08亲测成功)
  • 原文地址:https://www.cnblogs.com/NiceTime/p/8561142.html
Copyright © 2011-2022 走看看