本项目为微服务学习的实践笔记
全栈工程师 学习笔记 https://github.com/bage2014/study
Spring Boot 项目实践 https://github.com/bage2014/monitor
Spring Cloud 多模块实践 https://github.com/bage2014/my-app
- Spring Boot引导页: https://spring.io/guides
- MyBatis集成Spring Boot: https://github.com/mybatis/spring-boot-starter、https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start、https://github.com/mybatis/spring-boot-starter
- Spring Cloud集成Eureka https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.1.0.M3/single/spring-cloud-netflix.html
- Spring Cloud集成Ribbon https://blog.csdn.net/true1cc/article/details/81005637、https://blog.csdn.net/justlpf/article/details/80354161
- Spring Cloud集成Zuul https://blog.csdn.net/qq_34246546/article/details/79359323
- Spring Cloud集成Feign https://cloud.spring.io/spring-cloud-static/spring-cloud-openfeign/2.1.0.RC2/single/spring-cloud-openfeign.html#spring-cloud-feign
- Spring Cloud集成Hystrix https://cloud.spring.io/spring-cloud-static/spring-cloud-netflix/2.1.0.RC2/single/spring-cloud-netflix.html#_circuit_breaker_hystrix_clients
- Spring Cloud Config https://cloud.spring.io/spring-cloud-static/spring-cloud-config/2.1.0.RC2/single/spring-cloud-config.html
- Spring Cloud Sleuth https://spring.io/projects/spring-cloud-sleuth#overview
- 非Spring Boot Web项目 注册节点到Eureka Server并提供服务 https://blog.csdn.net/qq_32193151/article/details/72559783
- Spring Cloud Gateway https://cloud.spring.io/spring-cloud-gateway/single/spring-cloud-gateway.html
- Spring Cloud Gateway运行时动态配置网关 https://my.oschina.net/tongyufu/blog/1844573
- Spring Cloud Bus https://cloud.spring.io/spring-cloud-bus/spring-cloud-bus.html、https://spring.io/projects/spring-cloud-bus#overview
- SpringCloud之消息总线Spring Cloud Bus实例 https://blog.csdn.net/smartdt/article/details/79073765
- Centralized Configuration https://spring.io/guides/gs/centralized-configuration/
- Spring Cloud Config https://cloud.spring.io/spring-cloud-config/spring-cloud-config.html
- Spring Cloud Stream Preface https://cloud.spring.io/spring-cloud-static/spring-cloud-stream/2.2.0.RELEASE/spring-cloud-stream.html#spring-cloud-stream-reference
Spring Cloud Alibaba
https://spring.io/projects/spring-cloud-alibaba
https://spring-cloud-alibaba-group.github.io/github-pages/2021/en-us/index.html
http://c.biancheng.net/springcloud/what-is-alibaba.html
- study-micro-services-h2 数据库依赖
- study-micro-services-organization 组织机构服务
- study-micro-services-spring-boot web服务、spring boot服务
- study-micro-services-eureka spring cloud与eureka的server服务
- study-micro-services-eureka-server2 server服务2,与cloud-server3相互注册,服务名称为:cloud-server2
- study-micro-services-eureka-server3 server服务3,与cloud-server2相互注册,服务名称为:cloud-server3
- study-micro-services-eureka-client1 client服务1,注册到study-micro-services-eureka 服务名称为:cloud-client
- study-micro-services-eureka-client2 client服务2,注册到study-micro-services-eureka 服务名称为:cloud-client
- study-micro-services-eureka-client3 client服务3,注册到cloud-server2和cloud-server3, 服务名称为:cloud-client
- study-micro-services-ribbon 负载均衡服务, 服务名称为:cloud-ribbon
- study-micro-services-zuul 网关服务, 服务名称为:cloud-zuul
- study-micro-services-multi-datasources 多数据源Spring Boot 服务
- study-micro-services-feign Feign服务,注册到cloud-server, 服务名称为:cloud-feign
- study-micro-services-hystrix Hystrix服务,注册到cloud-server, 服务名称为:cloud-hystrix
- study-micro-services-config Config服务,注册到cloud-server, 服务名称为:cloud-config
- study-micro-services-sleuth Sleuth服务,注册到cloud-server, 服务名称为:cloud-sleuth
- study-micro-services-zuul-dynamic-routes 动态路由网关服务, 服务名称为:cloud-zuul-dynamic-routes
- study-micro-services-client4 非Spring boot服务, 服务名称为:cloud-client-not-springboot
- study-micro-services-gateway Spring网关服务, 服务名称为:cloud-gateway
- study-micro-services-gateway-dynamic Spring 动态路由网关服务, 服务名称为:cloud-gateway
- study-micro-services-bus Spring Cloud Bus 服务, 服务名称为:cloud-bus
- study-micro-services-bus-client Spring Cloud Bus 客户端 服务, 服务名称为:cloud-bus-client
- study-micro-services-stream Spring Cloud Stream 客户端 服务, 服务名称为:cloud-stream
- 启动注册中心 study-micro-services-eureka
- 启动注册中心2 study-micro-services-eureka-server2
- 启动注册中心3 study-micro-services-eureka-server3
- 其他项目,随机启动即可
- 端口 8761 http://localhost:8761/
- 端口 8762 http://localhost:8762/
- 端口 8763 http://localhost:8763/
- 应用名称 cloud-client
- 端口 8001 http://localhost:8001/
- 应用名称 cloud-client
- 端口 8002 http://localhost:8002/
- 请求客户端元信息 http://localhost:8082/eurekaClient/services?serviceId=CLOUD-CLIENT
- 应用名称 cloud-client
- 端口 8003 http://localhost:8003/
- 应用名称 cloud-ribbon
- 端口 8088 http://localhost:8088/
- 轮询负载用例 http://localhost:8088/eurekaClient/clients/CLOUD-CLIENT
- 访问非Spring Boot Web项目用例(非Spring Boot服务context为 / ) http://localhost:8088/eurekaClient/not-springboot/clients/
- 应用名称 cloud-zuul
- 端口 8888 http://localhost:8888/
- 网关请求用例 http://localhost:8888/api-zuul-ribbon/cloud-ribbon/eurekaClient/clients/CLOUD-CLIENT
- 网关路由到client5 http://localhost:8888/cloud-client5/
- 请求超时回调验证用例 http://localhost:8888/cloud-client5/timeoutRequest/
- 应用名称
- 端口 8080 http://localhost:8080/
- 应用名称 cloud-feign
- 端口 8808 http://localhost:8808/
- 网关请求用例 http://localhost:8808/eurekaClient/feign
- 应用名称 cloud-hystrix
- 端口 8098 http://localhost:8098/
- 请求服务成功用例 http://localhost:8098/hystrixClient/rest/success
- 请求服务失败用例,此接口不存在 http://localhost:8098/hystrixClient/rest/error
- 请求Hystrix监控用例 http://localhost:8098/hystrix
- 应用名称 cloud-config
- 端口 8099 http://localhost:8099/
- git仓库 https://github.com/bage2014/config-center
- 应用名称 cloud-config-client
- 端口 8909 http://localhost:8909/
- 配置请求用例 http://localhost:8909/config
- 配置刷新 http://localhost:8909/actuator/refresh
配置中心-服务端
- 应用名称 cloud-sleuth
- 端口 8909 http://localhost:8909/
- Sleuth 请求 http://localhost:8909/eurekaClient/feign
- 应用名称 cloud-zuul-dynamic-routes
- 请求用例
- 端口 8071 http://localhost:8071/
- 不存在路由client7 http://localhost:8071/client7/
- 存在路由client5 http://localhost:8071/client5/
- 增加路由client7 http://localhost:8071/route/insert/
- 刷新路由(后30s生效) http://localhost:8071/client7/
- 查询所有路由 http://localhost:8071/route/query/all
- 再次请求之前不存在路由client7,此时已经存在 http://localhost:8071/client7/
- 删除路由(刷新后30s生效) http://localhost:8071/route/delete/10086
- 再次请求路由client7,发现已经不存在 http://localhost:8071/client7/
- 简单测试
- 请求client6
ab -c 200 -n 200 -k http://172.17.17.188:8071/client6
- 应用名称 cloud-client-not-springboot
- 端口 8080(context为 / ) http://localhost:8080/hello
- 应用名称 cloud-client5
- 端口 8005 http://localhost:8005/
- 请求超时回调验证用例 http://localhost:8888/cloud-client5/timeoutRequest/
- 应用名称 cloud-client6
- 端口 8006 http://localhost:8006/
- 应用名称 cloud-gateway
- 端口 8888 http://localhost:8888/
- 请求client5(clien5中需要client5的mapping) http://localhost:8888/client5
- 应用名称 cloud-gateway
- 端口 8888 http://localhost:8888/
- 增加路由 http://localhost:8888/route/insert
- 验证路由 http://localhost:8888/client6
- 查询路由 http://localhost:8888/route/query/all
- 刷新路由 http://localhost:8888/route/refresh
- 应用名称 cloud-bus
- 端口 8801 http://localhost:8801/
- 应用名称 cloud-bus-client
- 端口 8802 http://localhost:8802/
- 请求用例(8801控制台即可看到打印的消息world) http://localhost:8802/hello/world
- 应用名称 cloud-stream
- 端口 8803 http://localhost:8803/
验证过程
- 应用启动,启动成功后,找到如下类似信息
`o.s.i.a.i.AmqpInboundChannelAdapter : started inbound.input.anonymous.bdmVXsWqSROwcFGGI3t4Sw`
- 登录 RabbitMQ 控制台,比如
[http://localhost:6527/](http://localhost:6527/)
- 选择 Queues Tab, 点击之前生成的queue Name
`inbound.input.anonymous.bdmVXsWqSROwcFGGI3t4Sw`
- 点击 Publish message, payload 内容为
`{"name":"Sam Spade"}`
- 点击 Publish message按钮,进行消息发布,即可在控制台打印
`Sam Spade`
导出jar到lib命令
mvn dependency:copy-dependencies -DoutputDirectory=lib
- 深入理解Eureka - Eureka架构综述 http://www.majunwei.com/view/201808130819216747.html
- 服务注册中心Eureka vs Zookeeper vs Consul https://www.cnblogs.com/daniels/p/10269140.html
- zuul入门(1)zuul 的概念和原理 https://www.cnblogs.com/lexiaofei/p/7080257.html