雪花新闻

干掉zuul:这就是代码写的最好的Java网关

封面:湖南湘西

我们还是先来看看新增功能,然后再讲故事。

体验新架构,10分钟搞定一个高可用高性能网关

启动 soul-admin

> wget  https://yu199195.github.io/jar/soul-admin.jar
> java -jar soul-admin.jar --spring.datasource.url="jdbc:mysql://你的url:3306/soul?useUnicode=true&characterEncoding=utf-8&useSSL=false"
--spring.datasource.username='you username' --spring.datasource.password='you password'

搭建属于你的网关

  <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
<version>2.2.2-RELEASE</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.2.2-RELEASE</version>
</dependency>

<!--soul gateway start-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-gateway</artifactId>
<version>2.2.0</version>
</dependency>

<!--soul data sync start use websocket-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-sync-data-websocket</artifactId>
<version>2.2.0</version>
</dependency>
spring:
main:
allow-bean-definition-overriding: true

management:
health:
defaults:
enabled: false
soul :
sync:
websocket :
urls: ws://localhost:9095/websocket //设置成你的soul-admin地址

体验新架构下的插件热插拔

  <!-- soul hystrix plugin start-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-plugin-hystrix</artifactId>
<version>2.2.0</version>
</dependency>
<!-- soul hystrix plugin end-->
   <!--soul alibaba dubbo plugin start-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-plugin-alibaba-dubbo</artifactId>
<version>2.2.0</version>
</dependency>
<!-- soul alibaba dubbo plugin end-->

2) 如果你使用apache-dubbo,那么你应该引入如下:

   <!--soul apache dubbo plugin start-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-plugin-apache-dubbo</artifactId>
<version>2.2.0</version>
</dependency>
<!-- soul apache dubbo plugin end-->
  1. 更多的使用请你参考:https://dromara.org/zh-cn/docs/soul/user-dubbo.html

  <!-- soul ratelimiter plugin start-->
<dependency>
<groupId>org.dromara</groupId>
<artifactId>soul-spring-boot-starter-plugin-ratelimiter</artifactId>
<version>2.2.0</version>
</dependency>
<!-- soul ratelimiter plugin end-->

Soul网关的特性

Soul网关有哪些使用场景,又有哪些值得你关注或者学习的?

首先我觉得还是实用主义,需要用到,才会去了解。那么在什么场景下,你需要用到呢?

后台管理web

公司入口网关(开放平台)

从发布2.2.0,谈谈近几年的开源体会

我是17年左右的时候,开始写开源项目的,最开始我和王亮一起讨论设计了LCN分布式事务,后面自己又陆续写了Hmily,Raincat,Myth等分布式事务中间件,再后来写了Soul网关,这一路走来,遇到很多很有意思的事,也遭受很多小白用户的摧残。总的感觉,一个好的开源项目,高扩展,可插拔的设计实在太重要了。

所以插件化设计,SPI可插拔设计势在必行。

SPI VS 可插拔

诚然SPI扩展方式,是可插拔的基石,但是他们又不完全等同。举个列子:假如我们先存储一条数据,你定好了SPI接口,也有Mysql,mongodb,elasticseach,zookeeper等等多种方式实现,现在你要考虑的是把它组合在一起项目里面,还是放在不同的项目,按需打包和加载呢?这些都是要考虑的,所以不能一股脑的SPI方式。

checkStyle

相关文章