Motan快速开始
请参考运维部署的内容,选择一种方式启动shenyu-admin
。比如,通过 本地部署 启动Apache ShenYu
后台管理系统。
启动成功后,需要在基础配置->
插件管理中,把motan
插件设置为开启。
启动网关,如果是通过源码的方式,直接运行shenyu-bootstrap
中的ShenyuBootstrapApplication
。
引入网关对的代理插件,在网关的 pom.xml
文件中增加如下依赖:
下载 。
运行org.apache.shenyu.examples.motan.service.TestMotanApplication
main方法启动项目。
成功启动会有如下日志:
2021-07-18 16:46:25.393 INFO 96 --- [ main] o.a.s.e.m.service.TestMotanApplication : Started TestMotanApplication in 3.89 seconds (JVM running for 4.514)
2021-07-18 16:46:25.396 INFO 96 --- [ main] info : [ZookeeperRegistry] Url (null) will set to available to Registry [zookeeper://localhost:2181/default_rpc/com.weibo.api.motan.registry.RegistryService/1.0/service]
2021-07-18 16:46:25.399 INFO 96 --- [ Thread-6] o.a.s.c.c.s.ShenyuClientShutdownHook : hook Thread-0 will sleep 3000ms when it start
2021-07-18 16:46:25.445 INFO 96 --- [ntLoopGroup-3-1] info : NettyChannelHandler channelActive: remote=/192.168.1.8:49739 local=/192.168.1.8:8002
2021-07-18 16:46:25.925 INFO 96 --- [or_consumer_-17] o.a.s.r.client.http.utils.RegisterUtils : motan client register success: {"appName":"motan","contextPath":"/motan","path":"/motan/hello","pathDesc":"","rpcType":"motan","serviceName":"org.apache.shenyu.examples.motan.service.MotanDemoService","methodName":"hello","ruleName":"/motan/hello","parameterTypes":"java.lang.String","rpcExt":"{\"methodInfo\":[{\"methodName\":\"hello\",\"params\":[{\"left\":\"java.lang.String\",\"right\":\"name\"}]}],\"group\":\"motan-shenyu-rpc\"}","enabled":true,"host":"192.168.220.1","port":8081,"registerMetaData":false}
打开插件列表 -> rpc proxy -> motan
可以看到插件规则配置列表:
下面使用postman
模拟http
的方式来请求你的服务: