基于netty实现的服务端NioMVC业务开发平台,提供性能监控,日志分析,动态扩展的功能。
ketty-srv模块基于netty实现支持自定义协议扩展的NioMVC高性能业务框架
协议Http
Ketty(自定义私有协议)
基于注解的mvc@Inject注入
@Path路径支持
@Param参数自动注入value
支持方法调用频率限制RateLimiter@Actionpublic class SimpleAction { @Inject private UserService userService; // 每秒最多可调用100次,超过100次丢弃, @Rate(value=100) @Interceptor(id = "echoInterceptor") @Path public User getUserByUid(@Param String uid) { return userService.getUserByUid(uid); }}拦截器example@Aroundpublic class EchoInterceptor extends BaseInterceptor { private final static Logger LOGGER = LoggerFactory.getLogger(EchoInterceptor.class); @Override public boolean before() { LOGGER.info("==============EchoInterceptor before========="); return true; } @Override public boolean after() { LOGGER.info("==============EchoInterceptor after========="); return true; }}KettyServerexample// nio mvc 业务server启动类examplenew KettyServer.Builder() .tcpNoDelay(true) .soKeepAlive(true) .setHttpProtocol() .host("localhost") .port(8888) .build() .start();// 测试jetty客户端public class JettClientTest { public static ClientSender clientSender = new ClientSender("localhost", 8888); public static void main(String[] args) throws Exception { KettyRequest request = new KettyRequest(); request.setUri("/simpleAction/getUserByUid"); JSONObject params = new JSONObject(); params.put("uid", "12345677"); request.setParameter(params); String result = clientSender.sendAndWait(request); System.out.println("result : " + result); }}HttpServerexample// nio mvc 业务server启动类examplepublic class SimpleServer { public static void main(String[] args) throws Exception { new KettyServer.Builder() .setKettyProtocol() .port(8888) .build() .start(); }}TODO支持自定义协议扩展
安全验证
性能优化
WebSocket协议的实现
ketty-client模块KettyServer高可用NIO客户端
Highavailability支持多个节点,节点不可用自动移除
Clientpool支持连接池
断链自动重连自动维护心跳ketty-codec模块编解码框架
KettyRequestheaderbodysizelenurimsgIdparamsMapbodyshort(2byte)short(2byte)stringint(4byte)mapJSONStringKettyResponseheaderbodysizelenmsgId(消息id)resCode(消息返回码)bodyshort(2byte)short(2byte)int(4byte)short(2byte)JSONStringketty-router模块服务代理模块,提供路由分发功能
ketty-monitor模块性能监控报警
ketty-analysis模块接口统计分析智能推荐
评论