简单 Netty RPC 框架 snrpc
- 授权协议: GPL
- 开发语言: Java
- 操作系统: 跨平台
- 软件首页: https://github.com/stefzhlg/snrpc
- 软件文档: https://github.com/stefzhlg/snrpc
软件介绍
snrpc 是一个简单的 Netty RPC 框架,使用 protostuff 1.07 作为序列化工具,使用 Netty-3.2.1 作为 NIO。
使用方式:
比如:
1. server class;
interface and implementor
// define an interface:
public interface SnRpcInterface {
public String getMessage(String param);
} // implement interface
public class SnRpcImpl implements SnRpcInterface {
public String getMessage(String param) {
return "hi,it is message from server...param+" + param;
}
}2, start server
SnRpcInterface inter = new SnRpcImpl();
SnRpcServer server = new SnNettyRpcServer(new Object[] { inter });
try {
server.start();
} catch (Throwable e) {
e.printStackTrace();
}3,config file
snrpcserver.properties
#tcpNoDelay snrpc.tcp.nodelay=true #call the bind method as many times as you want snrpc.tcp.reuseAddress=true #ISDEBUG snrpc.dev=true #TCP timeout snrpc.read.timeout=25000 #server port snrpc.http.port=8080
config.xml
<?xml version="1.0" encoding="UTF-8"?><application> <!-- rpc interface services --> <rpcServices> <rpcService name="SnRpcInterface" interface="org.stefan.snrpc.server.SnRpcInterface" overload="true"> <rpcImplementor class="org.stefan.snrpc.server.SnRpcImpl"/> </rpcService> </rpcServices></application>
4, client invoker
SnRpcConnectionFactory factory = new SnNettyRpcConnectionFactory(
"localhost", 8080);
factory = new PoolableRpcConnectionFactory(factory);
SnRpcClient client = new CommonSnRpcClient(factory);
try {
SnRpcInterface clazz = client.proxy(SnRpcInterface.class);
String message = clazz.getMessage("come on");
System.out.println("client receive message .... : " + message);
} catch (Throwable e) {
e.printStackTrace();
}要求
JDK6+
Maven 2
依赖
reflectasm-1.07.jar
asm-4.0.jar
log4j-1.2.16.jar
dom4j-1.6.1.jar
xml-apis-1.0.b2.jar
slf4j-api-1.6.6.jar
netty-3.2.1.Final.jar
jaxen-1.1.6.jar
protostuff-core-1.0.7.jar
protostuff-api-1.0.7.jar
protostuff-runtime-1.0.7.jar
protostuff-collectionschema-1.0.7.jar
commons-pool-1.6.jar
程序员的自我修养
陈逸鹤 / 清华大学出版社 / 2017-5 / 49.00
程序员作为一个职业、也作为一个群体,正逐渐从幕后走向前台,并以他们自己的能力加速改变着世界,也改变着人们生活的方方面面。然而,对于程序员,特别是年轻程序员们来说,如何理解自己的职业与发展,如何看待自己的工作与生活,这些问题往往比那些摆在面前的技术难题更让他们难以解答。 这本书从一个成熟程序员、一名IT管理者的角度,以杂记的形式为大家分享关于国内程序员职业生涯、个人发展、编程中的实践与认知乃至......一起来看看 《程序员的自我修养》 这本书的介绍吧!
