简单 Netty RPC 框架 snrpc

码农软件 · 软件分类 · RPC/XMLRPC项目 · 2019-04-11 17:12:18

软件介绍

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


本文地址:https://codercto.com/soft/d/3361.html

.NET设计规范

.NET设计规范

克瓦林纳 / 葛子昴 / 人民邮电出版社 / 2006-7 / 49.00元

本书为框架设计师和广大开发人员设计高质量的软件提供了权威的指南。书中介绍了在设计框架时的最佳实践,提供了自顶向下的规范,其中所描述的规范普遍适用于规模不同、可重用程度不同的框架和软件。这些规范历经.net框架三个版本的长期开发,凝聚了数千名开发人员的经验和智慧。微软的各开发组正在使用这些规范开发下一代影响世界的软件产品。. 本书适用于框架设计师以及相关的专业技术人员,也适用于高等院校相关专业......一起来看看 《.NET设计规范》 这本书的介绍吧!

JS 压缩/解压工具
JS 压缩/解压工具

在线压缩/解压 JS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

RGB HSV 转换
RGB HSV 转换

RGB HSV 互转工具