微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

simple-rpc 基于 netty 的 RPC 框架

程序名称:simple-rpc

授权协议: Apache

操作系统: 跨平台

开发语言: Java

simple-rpc 介绍

simple-rpc 是一款基于 netty 的 RPC 框架, 现有功能

  • 基本的客户端、服务端交互

  • 提供代理实现接口

  • spring 集成, xml配置和Java Config配置方式

  • 服务发布订阅 DONE

  • 断线重连 DONE

RoadMap

  • 服务心跳检测

  • 连接池

  • 服务注册发布功能

  • 服务管理、监控

  • 服务调用日志链路跟踪

  • 集成swagger功能,提供文档、测试、客户端生成

使用示例

// 服务接口
public interface IHello {
`
    String say(String hello);

    int sum(int a, int b);
    int sum(Integer a, Integer b);
}
// 服务实现
public class HelloImpl implements IHello {
    public String say(String hello) {
        return "return " + hello;
    }

    public int sum(int a, int b) {
        return a + b;
    }

    public int sum(Integer a, Integer b) {
        return a + b * 3;
    }

}

// 客户端代码
// beanJavaConfig方式
@Bean
    public CountService countService() {
        RpcclientWithLB rpcclientWithLB = new RpcclientWithLB("fyes-counter");
        rpcclientWithLB.setZkConn("10.4.105.252:2181");
        rpcclientWithLB.init();
        CountService countService = rpcclientWithLB.newProxy(CountService.class);
        return countService;
    }

// 服务端发布
// xml配置方式
<bean class="com.github.liuzhengyang.simplerpc.Serverfactorybean" init-method="start">
        <property name="serviceInterface" value="com.test.liuzhengyang.CountService"/>
        <property name="port" value="8888"/>
        <property name="serviceName" value="fyes-counter"/>
        <property name="serviceImpl" ref="countServiceImpl"/>
        <property name="zkConn" value="127.0.0.1:2181"/>

simple-rpc 官网

https://github.com/liuzhengyang/simple-rpc

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐