基于netty, spring,轻量的高性能分布式RPC服务框架。简单,易用,高效。
- 服务端支持多种序列化方式:fastjson,hession,kryo
- 服务端支持多种压缩方式:gzip,snappy
- 服务端可根据group进行线程隔离,支持基于spring对不同的group配置不同的业务线程池
- 支持注解配置,也支持spring xml配置
- 支持服务发现服务注册
- client端支持多种负载均衡策略和容灾策略
- client内置连接池
- 基于netty 4.x版本实现,高性能(win 8cpu单机8w+)
通过注解
@ServiceProvider
暴露服务,通过@MethodProvide
暴露方法默认配置,如:压缩方式,序列化方式,客户端超时时间
@ServiceProvider
public interface SampleService {
@MethodProvider
String say(String str);
}
基于注解
@ServiceExport
发布服务,基于注解@MethodExport
发布方法,
@ServiceExport
public class SampleServiceImpl implements SampleService {
@MethodExport
@Override
public String say(String str) {
return "say " + str;
}
}
application.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns="http://www.springframework.org/schema/beans"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.zhizus.forest.demo"/>
<bean id="forestServer" class="com.zhizus.forest.support.spring.ForestServerBean"/>
</beans>
public class SampleServer {
public static void main(String[] args) throws Exception {
new ClassPathXmlApplicationContext(new String[]{"application.xml"});
}
}
SampleService sampleService = Forest.from(SampleService.class);
String result = sampleService.say("hello");
23:10:10.295 [pool-1-thread-1] INFO MetricInterceptor 34 - methodName:/sampleService/say, current tps:83342, avgTime:0, maxTime:63, minTime:0
23:10:11.298 [pool-1-thread-1] INFO MetricInterceptor 34 - methodName:/sampleService/say, current tps:86271, avgTime:0, maxTime:63, minTime:0
23:10:12.295 [pool-1-thread-1] INFO MetricInterceptor 34 - methodName:/sampleService/say, current tps:86063, avgTime:0, maxTime:63, minTime:0
23:10:13.295 [pool-1-thread-1] INFO MetricInterceptor 34 - methodName:/sampleService/say, current tps:84305, avgTime:0, maxTime:63, minTime:0
- 服务降级功能
- http服务支持
- 跨语言协议支持
- 服务治理管理后台
Forest is released under the Apache License 2.0.