Solon rpc 1.2.18 发布,突出Rpc特性
Solon 是一个微型的Java RPC开发框架。项目从2018年启动以来,参考过大量前人作品;历时两年,3500多次的commit;内核保持0.1m的身材,超高的跑分,良好的使用体验。支持:Rpc、Rest api、Mvc 多种开发模式。
Solon 强调:克制 + 简洁 + 开放的原则;力求:更小、更快、更自由的体验。
所谓更小:
内核0.1m,最小开发单位0.2m(相比Dubbo、Springboot项目包,小到可以乎略不计)
所谓更快:
本机helloworld测试,Qps可达12万之多。可参考:《helloworld_wrk_test》
所谓更自由:(代码操控自由)
// 除了注入模式之外,还可以按需手动
//
//手动获取配置
Map<String,String> db = Solon.cfg().getMap("db");
//手动获取容器里的Bean
UserService userService = Aop.get(UserService.class);
//手动监听http post请求
Solon.global().post("/user/update", x-> userService.updateById(x.paramMap()));
本次版本重大变更:
一、突出Rpc 的特性
Solonn rpc 框架分为两部分:Nami 承载客户端的工作;Solon.boot 承载服务端的工作;Solon 做为容器贯穿前后
架构示意图

二、将Nami 分解为:内核、通道、编解码三块
使用时须引入有通道和编码包;也可根据需求定制自己的通道与编码方案
- 内核:org.noear:nami
- 通道:org.noear:nami.channel.* (支持http、 socket、websocket)
- 编码:org.noear:nami.coder.*
(一)已适配通道包
- org.noear:nami.channel.http.hutool
- org.noear:nami.channel.http.okhttp
- org.noear:nami.channel.socketd.jdksocket
- org.noear:nami.channel.socketd.netty
- org.noear:nami.channel.socketd.rsocket
- org.noear:nami.channel.socketd.smartsocket
- org.noear:nami.channel.socketd.websocket
(二)已适配解码包
- org.noear:nami.coder.fastjson
- org.noear:nami.coder.hessian
- org.noear:nami.coder.snack3
(三)支持Springboot集成
- org.noear:nami-springboot-starter (客户端集成)
- org.noear:springboot-solon-plugin(服务端集成)
Springboot 客户端集成示例 demo10.client_springboot
三、将集成包的打包方式由pom改为jar
- org.noear:solon-rpc 改为 jar
- org.noear:solon-web 改为 jar
附1:包引用使用示例
(一)http + json
- 客户端
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>1.2.18</version>
</parent>
<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>nami.coder.snack3</artifactId>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>nami.channel.http.okhttp</artifactId>
</dependency>
</dependencies>
public class ClientApp {
public static void main(String[] args) {
Solon.start(ClientApp.class, args);
//
// 默认使用json解码
//
HelloService helloService = Nami.builder()
.upstream(() -> "http://localhost:8080").create(HelloService.class);
String result = helloService.hello("noear");
System.out.println("Rpc result: " + result);
}
}
- 服务端
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>1.2.18</version>
</parent>
<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.serialization.snack3</artifactId>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.boot.jlhttp</artifactId>
</dependency>
</dependencies>
public class ServerApp {
public static void main(String[] args) {
Solon.start(ServerApp.class, args);
}
}
@Mapping("/")
@Component(remoting = true)
public class HelloServiceImpl implements HelloService {
@Override
public String hello(String name) {
return "hello: " + name;
}
}
(二)sockted + json
- 客户端
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>1.2.18</version>
</parent>
<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>nami.coder.hessian</artifactId>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>nami.channel.socketd.smartsocket</artifactId>
</dependency>
</dependencies>
public class ClientApp {
public static void main(String[] args) {
Solon.start(ClientApp.class, args);
//
// 默认使用json解码
//
HelloService helloService = Nami.builder()
.upstream(() -> "http://localhost:8080").decoder(HessianDecoder.instance).create(HelloService.class);
String result = helloService.hello("noear");
System.out.println("Rpc result: " + result);
}
}
- 服务端
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>1.2.18</version>
</parent>
<dependencies>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.serialization.hession</artifactId>
</dependency>
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon.boot.socketd.smartsocket</artifactId>
</dependency>
</dependencies>
public class ServerApp {
public static void main(String[] args) {
Solon.start(ServerApp.class, args);
}
}
@Mapping(value = "/",method = MethodType.SOCKET)
@Component(remoting = true)
public class HelloServiceImpl implements HelloService {
@Override
public String hello(String name) {
return "hello: " + name;
}
}
附2:更多示例
Solon rpc 1.2.18 发布,突出Rpc特性的更多相关文章
- cocoapods导入第三方库提示RPC failed curl 18 transfer
错误提示: error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: The rem ...
- git clone时RPC failed; curl 18 transfer closed with outstanding read data remaining
git clone时报RPC failed; curl 18 transfer closed with outstanding read data remaining 错误 原因1:缓存区溢出 解决方 ...
- Git 报错:git - error: RPC failed; curl 18 transfer closed with outstanding read data remaining 解决方案
error: RPC failed; curl 18 transfer closed with outstanding read data remaining because have error w ...
- git报错--RPC failed; curl 18 transfer closed with outstanding read data remaining
遇到的问题一: error: RPC failed; curl 18 transfer closed with outstanding read data remaining fata ...
- (转)git clone: error: RPC failed; result=18, HTTP code = 200 解决办法
git clone: error: RPC failed; result=18, HTTP code = 200 解决办法 分类: git2013-09-01 17:03 10753人阅读 评论(2) ...
- pod update更新error: RPC failed; curl 18 transfer closed with outstanding read data remaining
1. pod update 的时候出现下边的错误 error: RPC failed; curl 18 transfer closed with outstanding read data remai ...
- error: RPC failed; curl 18 transfer closed with outstanding read data remaining
报错: error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: The remot ...
- git clone报错error: RPC failed; curl 18 transfer closed with outstanding read data remaining
具体错误信息如下图: error: RPC failed; curl 18 transfer closed with outstanding read data remaining fatal: ...
- 解决git报错:error: RPC failed; curl 18 transfer closed with outstanding read data remaining 的方法
报错信息: error: RPC failed; curl 18 transfer closed with outstanding read data remainingfatal: the remo ...
随机推荐
- 关于phar反序列化——BUUCTF-[CISCN2019 华北赛区 Day1 Web1]Dropbox
太难了QAQ 先看看phar是啥https://blog.csdn.net/u011474028/article/details/54973571 简单的说,phar就是php的压缩文件,它可以把多个 ...
- 实验吧 Forms
0x1考察知识 html中value的作用 按钮中用的value 指的是 按钮上要显示的文本 比如'确定,删除 等等字样' 复选框用的value 指的是 这个复选框的值 单选框用的value 和复选框 ...
- Java程序员需要了解的底层知识(一)
硬件基础知识 - Java相关硬件 汇编语言的执行过程(时钟发生器 寄存器 程序计数器) 计算机启动过程 进程线程纤程的基本概念面试高频 - 纤程的实现 内存管理 进程管理与线程管理(进程与线程 ...
- sklearn决策树应用及可视化
from sklearn import datasets from sklearn.tree import DecisionTreeClassifier 1.载入iris数据集(from sklear ...
- 使用eslint将项目中的代码修改统一的缩进
背景 继承了组里师兄师姐写的项目的前端代码,但是是两个人写的,有两格缩进的,有四格缩进的,有字符串外用单引号的,有用双引号的. 于是搜索了一下,可以用eslint强制转化. eslint在github ...
- 什么时候使用transition?什么时候使用animation?
不同点: 1. 触发条件不同.transition通常和hover等事件配合使用,由事件触发.animation则和gif动态图差不多,立即播放. 2. 循环. animation可以设定循环次数. ...
- 网络QoS的平衡之道——音视频弱网对抗策略介绍
作者:网易智企云信资深音视频引擎开发工程师 王兴鹤 随着AI和5G的到来,音视频应用将变得越来越广泛,人们对音视频的品质需求也越来越高,视频分辨率已经从高清发展为超高清.VR,视频帧率也已出现60fp ...
- GYM100526I Interesting Integers
题目大意 定义一种 \(Gabonacci\) 数列: \[\begin{array}{c} G_1=a\\ G_2=b\\ G_i=G_{i-1}+G_{i-2} \end{array} \] 给定 ...
- JavaScript:浏览器的本地存储
cookie.localStorage.sessionStorage的使用 <!DOCTYPE html> <html lang="en"> <hea ...
- 使用uniapp开发项目来的几点心得体会,供新手参考参考
先说一下提前须要会的技术 要想快速入手uniapp的话,你最好提前学会vue.微信小程序开发,因为它几乎就是这两个东西的结合体,不然,你就只有慢慢研究吧. 为什么要选择uniapp??? 开发多个平台 ...