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 ...
随机推荐
- Jenkins Job间传递参数的一种方法
场景: Jenkins 中可以建多个Job,一般是主编译Job,多个子Job. 子Job要用主Job中的版本号,编译号. 1) 在主Job里面添加脚本命令: echo set MainVersion ...
- 个人作业三——ATM管理系统
一 作业信息 博客班级 https://edu.cnblogs.com/campus/ahgc/AHPU-se-JSJ18/ 作业要求 https://edu.cnblogs.com/campus/a ...
- 认识css常见的hack
一.认识css hack CSS Hack只要是来解决浏览器局部的兼容性问题,主要是因为每个浏览器对css的解析各不相同,导致输出到页面的效果的差异: 二.css hack的三种常见形式:css属性h ...
- NOI Online #2 提高组 游戏
没用二项式反演的菜比. 题目链接 Solution 非平局代表的树上祖先关系是比较好统计,(可以在处理一个点时,考虑用他去匹配他的子树中的东西)而平局的关系比较难统计.我们不妨求出至少 \(k\) 个 ...
- Java集合源码分析(七)——TreeMap
简介 TreeMap 是一个有序的key-value集合,它的内部是通过红黑树实现的. TreeMap 继承于AbstractMap,所以它是一个Map,即一个key-value集合. TreeMap ...
- Java集合源码分析(一)——集合框架
集合框架 集合框架如图所示 Java集合是Java提供的工具包,主要包括常用的数据结构,包括:集合.链表.队列.栈.数组.映射等. 集合的工具包位置是java.util.* 集合主要可以分为五类: L ...
- 【WHash】更有空间感的感知哈希
转载请注明出处 背景 在重复图识别领域,对于识别肉眼相同图片,感知哈希效果是很鲁棒的.上一篇文章 [PHash]更懂人眼的感知哈希 介绍的PHash识别效果很好,但是它有一个缺点,只关注低频信息,并没 ...
- window+nginx+php
今天在Windows上配置了下nginx,看了不少其他大牛们记录的博客,自己也操作了一番,记录一下备忘. nginx download: http://nginx.org/en/download.ht ...
- 【MySQL】Novicat 连接mysql 报错1251的问题处理,Novicat12 破解方法
1.远程连接时,报错 是因为我们的navicat版本太低 在网上查的是,出现这个原因是mysql8之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规则是ca ...
- EasyExcel导入
记录摸鱼的一天 技术栈:spring boot2.x+mybatis plus+easyExcel 2.2.6 生成简单的实体类等等等等 导入easyExcel的依赖 实体类 编写服务层 import ...