soul网关第三步-演示apache-dubbo服务

soul源码地址:https://github.com/dromara/soul

第三天,演示dubbo服务。

之前简单了解过dubbo,但都是基于照葫芦画瓢的状态,将功能配置上,按顺序启动服务进行调用。对其实现原理等,并不是很了解。希望借助这次学习,能够对dubbo的原理有更深入的学习和了解。

我们知道Dubbo是一种分布式服务框架,技术架构如图所示:

soul网关第三步-演示apache-dubbo服务_第1张图片

 

在soul网关中,服务提供者和消费者分别是谁呢?

当然服务的消费者是soul-admin,soul-examples-dubbo模块是服务的提供者。

我们打开网关界面dubbo的插件开关:

soul网关第三步-演示apache-dubbo服务_第2张图片

由于在项目中zookeeper为我们的注册中心,我们要配置单机的zookeeper服务。

配置方法连接可参考:https://www.iteye.com/blog/coolxing-1871009

启动zookeeper服务后,我们启动其中的soulBootstrapApplication服务。

soul网关第三步-演示apache-dubbo服务_第3张图片

此时控制台显示如下状态表示服务正常启动,我们成功注册了服务:

2021-01-17 00:11:43.686  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/findByIdsAndName","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"findByIdsAndName","ruleName":"/dubbo/findByIdsAndName","parameterTypes":"java.util.List,java.lang.String","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 
2021-01-17 00:11:43.707  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/findByStringArray","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"findByStringArray","ruleName":"/dubbo/findByStringArray","parameterTypes":"[Ljava.lang.String;","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 
2021-01-17 00:11:43.729  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/findByListId","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"findByListId","ruleName":"/dubbo/findByListId","parameterTypes":"java.util.List","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 
2021-01-17 00:11:43.744  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/batchSave","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"batchSave","ruleName":"/dubbo/batchSave","parameterTypes":"java.util.List","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 
2021-01-17 00:11:43.769  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/batchSaveAndNameAndId","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"batchSaveAndNameAndId","ruleName":"/dubbo/batchSaveAndNameAndId","parameterTypes":"java.util.List,java.lang.String,java.lang.String","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 
2021-01-17 00:11:43.801  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/saveComplexBeanTest","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"saveComplexBeanTest","ruleName":"/dubbo/saveComplexBeanTest","parameterTypes":"org.dromara.soul.examples.dubbo.api.entity.ComplexBeanTest","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 
2021-01-17 00:11:43.834  INFO 7107 --- [pool-2-thread-1] o.d.s.client.common.utils.RegisterUtils  : dubbo client register success: {"appName":"dubbo","contextPath":"/dubbo","path":"/dubbo/saveComplexBeanTestAndName","pathDesc":"","rpcType":"dubbo","serviceName":"org.dromara.soul.examples.dubbo.api.service.DubboMultiParamService","methodName":"saveComplexBeanTestAndName","ruleName":"/dubbo/saveComplexBeanTestAndName","parameterTypes":"org.dromara.soul.examples.dubbo.api.entity.ComplexBeanTest,java.lang.String","rpcExt":"{\"group\":\"\",\"version\":\"\",\"loadbalance\":\"random\",\"retries\":2,\"timeout\":10000,\"url\":\"\"}","enabled":true} 

 

页面刷新dubbo插件模块:

soul网关第三步-演示apache-dubbo服务_第4张图片

 

页面请求注册接口:

服务端日志展示:

2021-01-17 00:20:12.400  INFO 5166 --- [work-threads-16] o.d.soul.plugin.base.AbstractSoulPlugin  : dubbo selector success match , selector name :/dubbo
2021-01-17 00:20:12.403  INFO 5166 --- [work-threads-16] o.d.soul.plugin.base.AbstractSoulPlugin  : dubbo selector success match , selector name :/dubbo/findById

 

我们可以看到项目中有两个dubbo服务端,一个是alibaba,另一个是apache。这两个有什么区别呢?

留个思考题。

 

参考:

https://blog.csdn.net/zht741322694/article/details/83756101

你可能感兴趣的:(soul网关学习系列,java,zookeeper,网关)