License
/*
* Copyright 2002-2007 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
Jprotobuf-rpc-socket
Build status
Protobuf RPC是一种基于TCP协议的二进制高性能RPC通信协议实现。它以Protobuf作为基本的数据交换格式,支持完全基于POJO的发布方式,极大的简化了开发复杂性。
Features:
关联项目: https://github.com/jhunters/jprotobuf
golang 协议实现: https://github.com/baidu-golang/baidurpc
使用示例
环境要求:JDK 6+
使用Jprotobuf pre compile插件进行预编译,提升启动速度
filterClassPackage 用来指定进行预编译时需要扫描的package,目前只支持配置一个package名称
maven执行命令如下:
下载发行包
Qucik Start
Jprotobuf-rpc-socket基于JProtobuf基础上开发,可帮助大家开发中省去编写Google Protobuf的IDL描述文件的过程。
客户端开发
1.EchoService功用实现
EchoService 提供一个echo方法 ,参数对象EchoInfo只有一个message属性。 下面是EchoInfo对象定义
注解方式的定义可以极大简化大家的工作量,上面等同于下面的IDEL配置
2.定义EchoService接口
RPC的方法必须要指定@ProtobufRPC注解. serviceName与methodName要与服务端保持一致。 这里未指定methodName,则使用方法的名称 “echo”
3.创建RPC Client进行访问
服务端开发
1.开发服务实现类
服务发布的RPC方法必须用@ProtobufPRCService注解进行标识
2.发布RPC服务
上面的代码实现把 EchoServiceImpl 的RPC服务发布出去
更多使用说明
性能测试
机器配置:
性能测试结果如下(客户端与服务端部署在同一台机器中): 单线程:平均QPS: 9000+ 多线程:QPS: 最高 40000+
沟通群号:QQ: 644867264 ### 进群口令 jprotobuf