All Projects → yangzhenkun → Krpc

yangzhenkun / Krpc

Licence: mit
My RPC FrameWork(自己写的RPC框架)

Programming Languages

java
68154 projects - #9 most used programming language

Labels

Projects that are alternatives of or similar to Krpc

Twjitm
项目基于idea工作环境搭建的框架,添加mybatis3,spring4,springmvc4,以及redis。主要实现通过注解和反射自定义netty私有协议栈,实现在一条socket通道上传递不同的消息,采用支持tcp,udp和http协议
Stars: ✭ 26 (-76.79%)
Mutual labels:  rpc, netty
Nettythrift
Thrift on Netty, support TCP/HTTP/WebSocket at same port. support multiple Protocols at same time. multil Simple Clients with Connection Pool.
Stars: ✭ 60 (-46.43%)
Mutual labels:  rpc, netty
Takinrpc
RPC框架,基于netty,实现了远程调用、服务治理等功能
Stars: ✭ 13 (-88.39%)
Mutual labels:  rpc, netty
Getty
a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Stars: ✭ 532 (+375%)
Mutual labels:  rpc, netty
Fox
fox is a distributed RPC framework
Stars: ✭ 79 (-29.46%)
Mutual labels:  rpc, netty
Brpc Java
Java implementation for Baidu RPC, multi-protocol & high performance RPC.
Stars: ✭ 647 (+477.68%)
Mutual labels:  rpc, netty
Simple Rpc
RPC with service discovery base on netty
Stars: ✭ 103 (-8.04%)
Mutual labels:  rpc, netty
srpc
一款轻量 高性能的RPC框架,基于netty,整合spring,支持注册中心,多种序列化,负载均衡等
Stars: ✭ 78 (-30.36%)
Mutual labels:  netty, rpc
Easyrpc
EasyRpc is a simple, high-performance, easy-to-use RPC framework based on Netty, ZooKeeper and ProtoStuff.
Stars: ✭ 79 (-29.46%)
Mutual labels:  rpc, netty
Netty Stroll
RPC基础通信框架
Stars: ✭ 77 (-31.25%)
Mutual labels:  rpc, netty
Xxl Rpc
A high performance, distributed RPC framework.(分布式服务框架XXL-RPC)
Stars: ✭ 493 (+340.18%)
Mutual labels:  rpc, netty
Rpc Fromscratch
🌈 从零开始设计一个轻量级分布式 RPC 框架,基于 Spring + Netty + Protostuff + Zookeeper
Stars: ✭ 106 (-5.36%)
Mutual labels:  rpc, netty
Socket Mqtt
基于Netty+MQTT的高性能推送服务框架。支持普通Socket、MQTT、MQTT web socket协议。非常方便接入上层业务实现推送业务。
Stars: ✭ 314 (+180.36%)
Mutual labels:  rpc, netty
Servicetalk
A networking framework that evolves with your application
Stars: ✭ 656 (+485.71%)
Mutual labels:  rpc, netty
Armeria
Your go-to microservice framework for any situation, from the creator of Netty et al. You can build any type of microservice leveraging your favorite technologies, including gRPC, Thrift, Kotlin, Retrofit, Reactive Streams, Spring Boot and Dropwizard.
Stars: ✭ 3,392 (+2928.57%)
Mutual labels:  rpc, netty
Wheel
关于net nio os cache db rpc json web http udp tcp mq 等多个小工具的自定义实现
Stars: ✭ 45 (-59.82%)
Mutual labels:  rpc, netty
simple-rpc-plus
使用netty和zookeeper技术实现的远程调用框架
Stars: ✭ 16 (-85.71%)
Mutual labels:  netty, rpc
spring-boot-protocol
springboot功能扩充-netty动态协议,可以支持各种网络协议的动态切换(单端口支持多个网络协议).支持mmap,sendfile零拷贝,http请求批量聚合
Stars: ✭ 68 (-39.29%)
Mutual labels:  netty, rpc
Nettyrpc
NettyRPC is high performance java rpc server base on Netty,using kryo,hessian,protostuff support message serialization.
Stars: ✭ 1,131 (+909.82%)
Mutual labels:  rpc, netty
Jupiter
Jupiter是一款性能非常不错的, 轻量级的分布式服务框架
Stars: ✭ 1,372 (+1125%)
Mutual labels:  rpc, netty

docker pull Build Status

Logo

如何使用

编译好的服务端环境 release

1.服务端

解压后server文件夹中就是服务端环境,如demo所示,server/service中有一个user文件,就是我们部署的user服务,下面有两个必须的文件夹conf(配置文件)

log4j.xml是该服务日志的标准的log4j配置文件,如果想修改日志路径

<!-- 输出日志到文件  每天一个文件 -->
  	<appender name="dailyRollingFile"
  		class="org.apache.log4j.DailyRollingFileAppender">
  		<param name="Threshold" value="info"></param>
  		<param name="ImmediateFlush" value="true"></param>
  		<param name="File" value="D:/opt/krpc/log/user/krpc.log"></param>
  		<param name="DatePattern" value="'.'yyyy-MM-dd'.log'"></param>
  		<layout class="org.apache.log4j.PatternLayout">
  			<param name="ConversionPattern" value="[%d{yyyy-MM-dd HH:mm:ss\} %-5p] [%t] {%c:%L}-%m%n"></param>
  		</layout>
  	</appender> 

修改值即可

server.xml文件为服务的配置文件

<configuration>

<!-- 配置注册中心 如果不配置,则不使用 -->
<zk sessionTimeOut="20000" connectionTimeOut="20000">
        <addr>127.0.0.1:2181,127.0.0.1:3333</addr>
</zk>
<!-- 连接相关参数 -->
	<property>
		<!-- 该服务监听的本机IP和tcp端口 -->
		<connection ip="127.0.0.1" port="17999" timeout="3000"/>
		<!-- 最大接受请求(字节,默认值是1024) -->
		<netty maxBuf="655350"/>
	</property>
	
	
	<!-- 所有能提供服务的接口 -->
	<services>
		<!-- name的值为接口名字,客户端通过代理工程生成接口时需要, impl值为具体实现类全路径  -->
		<service name="userService" impl="com.a123.service.user.impl.UserServiceImpl"/>
	</services>
	
	
	
	</configuration>

一个服务中所有对外的接口必须在services中配置,规则如上注释所示。

编写服务端代码会需要一个接口包和一个实现包,将源码生成jar包后,放在server/service/user/lib中,这里以user服务为例,你可以自己定义这个文件名的名字来标识这个服务。

启动 启动在server/bin里面,执行

    java -jar com.krpc.server-0.0.1.jar 服务名

命令,查看日志,如果看到 启动成功,监听端口*** 的日志,恭喜你,服务端启动成功。

docker 启动服务

https://github.com/yangzhenkun/krpc/tree/master/docker

krpc提供了服务端镜像,所以每个服务都可以在krpc提供的dockerfile模版中进行修改构建自己的服务镜像

2.客户端

需要引入KRPC客户端,由于项目还没有发布到maven中央仓库,用户可以将client包发布到自己本地,或者直接将该com.krpc.client-0.0.1.jar包加入项目。

使用需要先调用KRPC.init("client配置文件")进行初始化 配置在client/client.xml中

    
    <!-- 配置注册中心-->
        <zk sessionTimeOut="2000" connectionTimeOut="2000">
            <addr>127.0.0.1:2181,127.0.0.1:3333</addr>
        </zk>
    
	<!-- 所连接的服务配置文件 name的值可以任意指定,只要在ProxyFactory.create的第二个参数值相同即可 -->
    <!--用户服务 -->
	<Service name="user" id="1" maxThreadCount="50">
		
        <Loadbalance>
			<!-- 请求超时时间(ms) -->
            <Server timeout="10000">
                <addr name="user1" host="127.0.0.1" port="17666" maxCurrentUser="50"/>
            </Server>
        </Loadbalance>
    </Service>

sercie的name的值必须

 
	UserService service = ProxyFactory.create(UserService.class, "user", "userService");

跟create中第二个参数一直。第三个参数为服务端实现的名字,需要跟服务端的配置文件一直。

3.要注意的事情

krpc.rar中的krpc相关包均为上面源码中生成

配置文件模板:https://github.com/yangzhenkun/krpc/tree/master/demo/config_file_template

这个RPC框架是我自己造轮子学习的,并没有真实在生产环境中使用,所以看到这个项目,希望大家可以交流学习技术,提交pr,issue,完善其性能及功能,争取让它可以用于生产环境

我个人博客中关于RPC及这个KRPC的源码原理解析会在这个专栏中写道 https://blog.csdn.net/column/details/22012.html

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].