基于 netty 实现的服务端 Nio MVC 业务开发平台,提供性能监控,日志分析,动态扩展的功能。
基于netty实现支持自定义协议扩展的Nio MVC高性能业务框架
Http
Ketty(自定义私有协议)
@Inject注入
@Path 路径支持
@Param参数自动注入value
@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); }}
@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; }}
// 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); }}
// nio mvc 业务server启动类examplepublic class SimpleServer { public static void main(String[] args) throws Exception { new KettyServer.Builder() .setKettyProtocol() .port(8888) .build() .start(); }}
支持自定义协议扩展
安全验证
性能优化
WebSocket协议的实现
KettyServer高可用NIO客户端
支持多个节点,节点不可用自动移除
支持连接池
编解码框架
服务代理模块,提供路由分发功能
性能监控 报警
接口统计分析 智能推荐