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 ...
随机推荐
- PyQt学习随笔:Qt Designer的Edit Buddies功能
在Qt Designer的Edit菜单下有个Edit Buddies(编辑伙伴关系)子菜单,该菜单的作用是将一个Label与其他控件关联起来,当Label控件设置了快捷键时,通过Label的快捷键就可 ...
- Leetcode学习笔记(3)
题目1 ID88 给你两个有序整数数组 nums1 和 nums2,请你将 nums2 合并到 nums1 中,使 num1 成为一个有序数组. 说明: 初始化 nums1 和 nums2 的元素数量 ...
- Kubernetes的Local Persistent Volumes使用小记
欢迎访问我的GitHub https://github.com/zq2599/blog_demos 内容:所有原创文章分类汇总及配套源码,涉及Java.Docker.Kubernetes.DevOPS ...
- 新挖个坑,准备学习一下databricks的spark博客
挖坑 https://databricks.com/blog 一.spark3.0特性(Introducing Apache Spark 3.0) 1.通过通过自适应查询执行,动态分区修剪和其他优化使 ...
- DarkMode(1):产品应用深色模式分析
为什么Dark Mode变得越来越流行 2018 年的 macOS Mojave 率先支持了深色外观,紧接着 Windows 10 在 2018 年的 10 月份大版本更新中,也引入了 Dark Mo ...
- Jmeter连接redis
介绍:现在有很多数据不是存储在数据库而是存储在Redis中 Redis数据库存储数据环境 不用每次都去数据库读取数据 可以有效的优化服务器性能. 下面介绍使用jmeter如何读取redis 一.首先创 ...
- ElasticSearch中head插件的简单用法
1.首先在左侧打开Query栏. 2.Query下方的第一栏是分别输入es的地址.端口号.index.type. 3.Query下方的第二栏是输入将要执行的方式,旁边的下拉框是辅助选择执行的类型,如图 ...
- [日常摸鱼]POJ2187 BeautyContest-旋转卡壳
原来这个念 旋转卡qia壳ke- 题意:求平面内给定点集里的最远点对,$n \leq 5e4$ 做法就是旋转卡壳啦,话说这题数据范围应该可以再大挺多的. #include<cstdio> ...
- Angular入门,开发环境搭建,使用Angular CLI创建你的第一个Angular项目
前言: 最近一直在使用阿里的NG-ZORRO(Angular组件库)开发公司后端的管理系统,写了一段时间的Angular以后发现对于我们.NET后端开发而言真是非常的友善.因此这篇文章主要是对这段时间 ...
- MySQL索引的使用是怎么样的?5个点轻松掌握!
一.前言 在MySQL中进行SQL优化的时候,经常会在一些情况下,对MySQL能否利用索引有一些迷惑. 譬如: MySQL 在遇到范围查询条件的时候就停止匹配了,那么到底是哪些范围条件? MySQL ...