Solon 1.8.0 发布,云原生微服务开发框架

2022-12-01,,,,

相对于 Spring Boot 和 Spring Cloud 的项目

启动快 5 ~ 10 倍
qps 高 2~ 3 倍
运行时内存节省 1/3 ~ 1/2
打包可以缩小到 1/2 ~ 1/10(比如,90Mb 的变成了 9Mb)
基于 app.name 进行注册发现 与 k8s svc 相互对应
支持 Service Mesh 架构部署方案

关于 Solon

Solon 是一个更现代感的应用开发框架,轻量、开放生态型的。支持 Web、Data、Job、Remoting、Cloud 等任何开发场景。

强调,克制 + 简洁 + 开放 + 生态的原则
力求,更小、更少、更快、更自由的体验

目前有近130个生态插件,含盖了日常开发的各种需求:

本次主要更新内容

新增 solon.extend.hotplug 插件(提供业务插件 '热插拨' 和 '热管理' 支持)

public class DemoApp {
public static void main(String[] args) {
Solon.start(App.class, args, app -> {
//添加待管理的插件
PluginManager.add("add1", "/x/x/x.jar");
PluginManager.add("add2", "/x/x/x2.jar"); app.get("start", ctx -> {
//启动插件
PluginManager.start("add1");
ctx.output("OK");
}); app.get("stop", ctx -> {
//停止插件
PluginManager.stop("add1");
ctx.output("OK");
});
});
}
}

更多介绍看官网的:solon.extend.hotplug

调整 AopContext ,更具隔离性
调整 AopContext::beanOnloaded 参数由 Runnable 改为:Consumer
调整 Plugin::start 参数由 SolonApp 改为:AopContext

public class Plugin1Impl implements Plugin {
@Override
public void start(AopContext context) {
//通过当前上下文扫描,具有隔离性
context.beanScan(Plugin1Impl.class); context.beanOnloaded(ctx->{
//回调有上下文信息,方便做多插件可复用的设计
});
}
}

修复 @Cache 在函数里有逗号时无法删除缓存的问题

@Controller
public class DemoController {
/**
* 执行结果缓存10秒,使用 key=test_${label} 并添加 test 标签
* */
@Cache(key="test_${label}", tags = "test" , seconds = 10)
@Mapping("/cache/")
public Object test(int label) {
return new Date();
} /**
* 执行后,清除 标签为 test 的所有缓存
* */
@CacheRemove(tags = "test")
@Mapping("/cache/clear")
public String clear() {
return "清除成功(其实无效)-" + new Date();
} /**
* 执行后,更新 key=test_${label} 的缓存
* */
@CachePut(key = "test_${label}")
@Mapping("/cache/clear2")
public Object clear2(int label) {
return new Date();
}
}

修复 Gateway 对默认接口识别失效的问题

@Mapping("/api/v3/app/**")
@Component
public class ApiGatewayV3 extends UapiGateway {
@Override
protected void register() {
filter(new BreakerFilter()); //融断 before(new StartHandler()); //开始计时
before(new ParamsParseHandler()); //参数解析
before(new ParamsSignCheckHandler(new Md5Encoder())); //参数签名较验
before(new ParamsRebuildHandler(new AesDecoder())); //参数重构 after(new OutputBuildHandler(new AesEncoder())); //输出构建
after(new OutputSignHandler(new Md5Encoder())); //输出签名
after(new OutputHandler()); //输出
after(new EndBeforeLogHandler()); //日志
after(new EndHandler("v3.api.app")); //结束计时 //添加一批具体的接口处理Bean
addBeans(bw -> "api".equals(bw.tag()));
}
}

修复 rocketmq-solon-plugin ,消费异常时仍返回成功的问题
优化 rabbitmq-solon-plugin ,消费异常时的处理

项目地址

gitee:https://gitee.com/noear/solon
github:https://github.com/noear/solon
website: https://solon.noear.org

Solon 1.8.0 发布,云原生微服务开发框架的相关教程结束。

《Solon 1.8.0 发布,云原生微服务开发框架.doc》

下载本文的Word格式文档,以方便收藏与打印。