源码下载地址:https://github.com/dromara/soul
1)先把源码克隆下来:
git clone [email protected]:dromara/soul.git
2)导入idea:
File-Open-选中源码工程导入
3)编译优化命令:
mvn clean package install -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -Drat.skip=true -Dcheckstyle.skip=true
Soul 是基于 WebFlux 实现的响应式的 API 网关,具有异步、高性能、跨语言等特点
步骤:
1)、将数据库连接地址改为本机数据库地址,涉及修改文件为soul-admin模块中resources目录的application.yml文件,涉及修改内容如下:
datasource:
url: jdbc:mysql://localhost:3306/soul?useUnicode=true&characterEncoding=utf-8
username: root
password:
2)、运行soul-admin模块中的SoulAdminBootstrap类,启动soul-admin模块,有如下日志打印表示启动成功
2021-01-14 18:42:15.088 INFO 23180 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 9095 (http) with context path ''
2021-01-14 18:42:15.093 INFO 23180 --- [ main] o.dromara.soul.admin.SoulAdminBootstrap : Started SoulAdminBootstrap in 8.672 seconds (JVM running for 13.272)
3)、通过访问http://127.0.0.1:9095地址登录Soul Admin 控制台,如下图所示:
输入密码admin/123456登录后首页如下:
1)运行soul-bootstrap模块的SoulBootstrapApplication类,启动soul-bootstrap模块,有如下日志打印表示启动成功
2021-01-14 19:25:45.075 INFO 19940 --- [ main] o.d.s.b.SoulBootstrapApplication : Starting SoulBootstrapApplication on LAPTOP-UTMT03GB with PID 19940 (D:\geek\source\soul\soul\soul-bootstrap\target\classes started by wenhu in D:\geek\source\soul\soul)
2021-01-14 19:25:45.076 INFO 19940 --- [ main] o.d.s.b.SoulBootstrapApplication : The following profiles are active: local
2021-01-14 19:25:46.746 INFO 19940 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2021-01-14 19:25:46.750 INFO 19940 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2021-01-14 19:25:46.797 INFO 19940 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 18ms. Found 0 Redis repository interfaces.
2021-01-14 19:25:48.006 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[global] [org.dromara.soul.plugin.global.GlobalPlugin]
2021-01-14 19:25:48.006 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[sign] [org.dromara.soul.plugin.sign.SignPlugin]
2021-01-14 19:25:48.006 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[waf] [org.dromara.soul.plugin.waf.WafPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[rate_limiter] [org.dromara.soul.plugin.ratelimiter.RateLimiterPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[hystrix] [org.dromara.soul.plugin.hystrix.HystrixPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[resilience4j] [org.dromara.soul.plugin.resilience4j.Resilience4JPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[divide] [org.dromara.soul.plugin.divide.DividePlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[webClient] [org.dromara.soul.plugin.httpclient.WebClientPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[divide] [org.dromara.soul.plugin.divide.websocket.WebSocketPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[alibaba-dubbo-body-param] [org.dromara.soul.plugin.alibaba.dubbo.param.BodyParamPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[dubbo] [org.dromara.soul.plugin.alibaba.dubbo.AlibabaDubboPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[monitor] [org.dromara.soul.plugin.monitor.MonitorPlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[response] [org.dromara.soul.plugin.httpclient.response.WebClientResponsePlugin]
2021-01-14 19:25:48.007 INFO 19940 --- [ main] o.d.s.w.configuration.SoulConfiguration : load plugin:[response] [org.dromara.soul.plugin.alibaba.dubbo.response.DubboResponsePlugin]
2021-01-14 19:25:48.186 INFO 19940 --- [ main] b.s.s.d.w.WebsocketSyncDataConfiguration : you use websocket sync soul data.......
2021-01-14 19:25:48.336 INFO 19940 --- [ main] o.d.s.p.s.d.w.WebsocketSyncDataService : websocket connection is successful.....
2021-01-14 19:25:48.464 INFO 19940 --- [ main] o.s.b.a.e.web.EndpointLinksResolver : Exposing 2 endpoint(s) beneath base path '/actuator'
2021-01-14 19:25:50.329 INFO 19940 --- [ main] o.s.b.web.embedded.netty.NettyWebServer : Netty started on port(s): 9195
2021-01-14 19:25:50.332 INFO 19940 --- [ main] o.d.s.b.SoulBootstrapApplication : Started SoulBootstrapApplication in 6.724 seconds (JVM running for 12.016)
2)通过观察启动日志,在soul-bootstrap模块启动后,会跟soul-admin模块建立起websocket连接,soul-bootstrap模块跟websocket连接的日志如下:
2021-01-14 19:25:48.186 INFO 19940 --- [ main] b.s.s.d.w.WebsocketSyncDataConfiguration : you use websocket sync soul data.......
2021-01-14 19:25:48.336 INFO 19940 --- [ main] o.d.s.p.s.d.w.WebsocketSyncDataService : websocket connection is successful.....
soul-admin模块跟websocket连接相关的日志如下:
2021-01-14 19:25:48.349 INFO 23180 --- [0.0-9095-exec-5] o.d.s.a.l.websocket.WebsocketCollector : websocket on open successful....
查看soul-bootstrap模块中的application-local.yml文件的配置,确实存在websocket相关配置,如下:
soul :
file:
enabled: true
corss:
enabled: true
dubbo :
parameter: multi
sync:
websocket :
urls: ws://localhost:9095/websocket
目前初步猜想soul-bootstrap是通过启动时和soul-admin模块建立websocket连接来实现当管理控制台配置数据发生变化时,动态刷新缓存在JVM内存中的配置数据的,后续通过阅读源码的方式来验证这个猜想。
soul官方介绍
芋道soul极简入门
soul开源网关项目搭建学习
极客时间Java进阶训练营Soul网关介绍