首页
统计
关于
Search
1
Sealos3.0离线部署K8s集群
1,085 阅读
2
类的加载
742 阅读
3
Spring Cloud OAuth2.0
726 阅读
4
SpringBoot自动装配原理
691 阅读
5
集合不安全问题
586 阅读
笔记
Java
多线程
注解和反射
JVM
JUC
设计模式
Mybatis
Spring
SpringMVC
SpringBoot
MyBatis-Plus
Elastic Search
微服务
Dubbo
Zookeeper
SpringCloud
Nacos
Sentinel
数据库
MySQL
Oracle
PostgreSQL
Redis
MongoDB
工作流
Activiti7
Camunda
消息队列
RabbitMQ
前端
HTML5
CSS
CSS3
JavaScript
jQuery
Vue2
Vue3
Linux
容器
Docker
Kubernetes
Python
FastApi
登录
Search
标签搜索
Java
CSS
mysql
RabbitMQ
JavaScript
Redis
JVM
Mybatis-Plus
Camunda
多线程
CSS3
Python
Spring Cloud
注解和反射
Activiti
工作流
SpringBoot
Mybatis
Spring
html5
蘇阿細
累计撰写
389
篇文章
累计收到
4
条评论
首页
栏目
笔记
Java
多线程
注解和反射
JVM
JUC
设计模式
Mybatis
Spring
SpringMVC
SpringBoot
MyBatis-Plus
Elastic Search
微服务
Dubbo
Zookeeper
SpringCloud
Nacos
Sentinel
数据库
MySQL
Oracle
PostgreSQL
Redis
MongoDB
工作流
Activiti7
Camunda
消息队列
RabbitMQ
前端
HTML5
CSS
CSS3
JavaScript
jQuery
Vue2
Vue3
Linux
容器
Docker
Kubernetes
Python
FastApi
页面
统计
关于
搜索到
31
篇与
的结果
2020-12-31
Hystrix服务熔断
Hystrix服务熔断服务熔断:熔断机制是对应雪崩效应的一种微服务链路保护机制。当某个微服务不可用或响应时间太长,会进行服务的降级,进而熔断该节点微服务的调用,快速返回“错误的响应信息”,当该节点的调用恢复正常之后注册中心将其恢复至调用链路。Spring Cloud的熔断机制通过Hystrix实现,它会监控微服务间的调用状况,当失败的调用到一定阈值(缺省5秒内20次调用失败),就会启动熔断机制。具体实例:1、导入依赖<dependencies> <!--需要拿到实体类,配置api module--> <dependency> <groupId>com.sw</groupId> <artifactId>springcloud-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> </dependency> <dependency> <groupId>ch.qos.logback</groupId> <artifactId>logback-core</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-test</artifactId> <scope>test</scope> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> <version>1.4.7.RELEASE</version> </dependency> <!--actuator监控信息--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> <!--Hystrix--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-hystrix</artifactId> <version>1.4.7.RELEASE</version> </dependency> </dependencies>2、daopackage com.sw.springcloud.dao; import com.sw.springcloud.pojo.Dept; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; import java.util.List; /** * @Author suaxi * @Date 2020/12/28 21:34 */ @Mapper @Repository public interface DeptDao { public boolean addDept(Dept dept); public Dept findDept(Long id); public List<Dept> findAll(); } 3、Service接口package com.sw.springcloud.service; import com.sw.springcloud.pojo.Dept; import java.util.List; /** * @Author suaxi * @Date 2020/12/28 21:34 */ public interface DeptService { public boolean addDept(Dept dept); public Dept findDept(Long id); public List<Dept> findAll(); } Service实现:package com.sw.springcloud.service; import com.sw.springcloud.dao.DeptDao; import com.sw.springcloud.pojo.Dept; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.List; /** * @Author suaxi * @Date 2020/12/28 21:42 */ @Service public class DeptServiceImpl implements DeptService{ @Autowired private DeptDao deptDao; @Override public boolean addDept(Dept dept) { return deptDao.addDept(dept); } @Override public Dept findDept(Long id) { return deptDao.findDept(id); } @Override public List<Dept> findAll() { return deptDao.findAll(); } } 4、controller注:hystrix熔断需开启注解@HystrixCommand(fallbackMethod = "hystrixGet"),且提供熔断后的备选方法package com.sw.springcloud.controller; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import com.sw.springcloud.pojo.Dept; import com.sw.springcloud.service.DeptService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import java.util.List; /** * @Author suaxi * @Date 2020/12/28 21:44 * 提供RestFul服务 */ @RestController public class DeptController { @Autowired private DeptService deptService; @GetMapping("/dept/get/{id}") @HystrixCommand(fallbackMethod = "hystrixGet") public Dept get(@PathVariable("id")Long id){ Dept dept = deptService.findDept(id); if (dept==null){ throw new RuntimeException("不存在id为"+id+"的用户,或者信息无法找到"); } return dept; } //熔断后的备选方法 public Dept hystrixGet(@PathVariable("id")Long id){ Dept dept = deptService.findDept(id); return new Dept() .setDeptno(id) .setDname("不存在id为"+id+"的用户,或者信息无法找到,null-->@Hystrix") .setDb_source("No message in MySQL"); } } 5、SpringBoot启动类开启Hystrix注解支持package com.sw.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; /** * @Author suaxi * @Date 2020/12/28 21:49 */ @SpringBootApplication @EnableEurekaClient //服务启动后自动注册到Eureka中 @EnableDiscoveryClient //开启服务发现 @EnableCircuitBreaker //开启熔断器支持 public class DeptProviserHystrix_8088 { public static void main(String[] args) { SpringApplication.run(DeptProviserHystrix_8088.class,args); } } 6、appliction.yml配置(此处以单个节点配置为例,实际开发中的微服务节点不止一个)server: port: 8088 #mybatis配置 mybatis: type-aliases-package: com.sw.springcloud.pojo config-location: classpath:mybatis/mybatis-config.xml mapper-locations: classpath:mybatis/mapper/*.xml #Spring配置 spring: application: name: springcloud-provider-dept datasource: type: com.alibaba.druid.pool.DruidDataSource driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/db01?useUnicode=true&character=UFT-8 username: root password: 123456 #配置Eureka,配置服务注册到哪里 eureka: client: service-url: defaultZone: http://eureka7001.com:7001/eureka/,http://eureka7002.com:7002/eureka/,http://eureka7003.com:7003/eureka/ instance: instance-id: springcloud-provider_dept-hystrix_8088 #修改Eureka默认描述信息 #info配置 info: app.name: springcloud-demo company.name: suaxi 当整个微服务调用出现问题时,前端反馈给用户的信息不是错误代码,而是熔断后的备选方法中定义的信息(即快速返回出现错误的响应信息)。用户正常查询信息:查询数据库中不存在的信息,即服务调用出现异常:
2020年12月31日
183 阅读
0 评论
0 点赞
2020-12-31
Feign负载均衡
Feign负载均衡Feign是声明式的web service客户端,Spring Cloud集成了Ribbon和Eureka,可以在使用Feign时提供负载均衡的http客户端。相较于Ribbon,Feign通过创建接口和注解使用,即可完成对服务提供方的接口绑定,简化了使用Spring Cloud Ribbon时,自动封装服务调用客户端的开发量。具体实例:1、导入依赖<dependencies> <!--feign--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-feign</artifactId> <version>1.4.7.RELEASE</version> </dependency> <!--Ribbon--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-ribbon</artifactId> <version>1.4.7.RELEASE</version> </dependency> <!--Eureka--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> <version>1.4.7.RELEASE</version> </dependency> <dependency> <groupId>com.sw</groupId> <artifactId>springcloud-api</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>2、Controllerpackage com.sw.springcloud.controller; import com.sw.springcloud.pojo.Dept; import com.sw.springcloud.service.DeptClientService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; import java.util.List; /** * @Author suaxi * @Date 2020/12/28 22:16 */ @RestController public class DeptConsumerController { @Autowired private DeptClientService client; @RequestMapping(value = "/consumer/dept/add",produces = {"application/json;charset=UTF-8"}) public boolean add(Dept dept){ return this.client.addDept(dept); } @RequestMapping(value = "/consumer/dept/get/{id}",produces = {"application/json;charset=UTF-8"}) public Dept get(@PathVariable("id")Long id){ return this.client.findById(id); } @RequestMapping(value = "/consumer/dept/list",produces = {"application/json;charset=UTF-8"}) public List<Dept> list(){ return this.client.findAll(); } } 3、注册到Spring容器中package com.sw.springcloud.config; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; /** * @Author suaxi * @Date 2020/12/28 22:15 */ @Configuration public class ConfigBean { @Bean @LoadBalanced //注册Ribbon public RestTemplate getRestTemplate(){ return new RestTemplate(); } } 4、SpringBoot启动类开启Feign注解package com.sw.springcloud; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.openfeign.EnableFeignClients; import org.springframework.context.annotation.ComponentScan; /** * @Author suaxi * @Date 2020/12/28 22:29 */ @SpringBootApplication @EnableEurekaClient @EnableFeignClients(basePackages = {"com.sw.springcloud"}) public class FeignDeptConsumer_80 { public static void main(String[] args) { SpringApplication.run(FeignDeptConsumer_80.class,args); } }
2020年12月31日
101 阅读
0 评论
0 点赞
2020-12-30
Ribbon
RibbonSpring Cloud Ribbon是基于NetFlix Ribbon实现的客户端负载均衡工具主要功能是提供客户端的软件负载均衡算法,将NetFlix的中间层服务连接在一起。在配置文件中列出LoadBalancer后面的所有机器,Ribbon会自动帮助你基于某些规则(轮询、随机数轮询、随机连接等)去连接这些服务。自定义算法:package com.sw.myrule; import com.netflix.client.config.IClientConfig; import com.netflix.loadbalancer.AbstractLoadBalancerRule; import com.netflix.loadbalancer.ILoadBalancer; import com.netflix.loadbalancer.Server; import java.util.List; import java.util.concurrent.ThreadLocalRandom; /** * @Author suaxi * @Date 2020/12/29 16:44 */ public class MyRandomRule extends AbstractLoadBalancerRule { //自定义算法:每个服务访问5次之后,换下一个 private int total = 0; //被调用的次数 private int currentIndex = 0; //当前是谁在提供服务 public Server choose(ILoadBalancer lb, Object key) { if (lb == null) { return null; } Server server = null; while (server == null) { if (Thread.interrupted()) { return null; } List<Server> upList = lb.getReachableServers(); //获取活着的服务 List<Server> allList = lb.getAllServers(); //获取所有服务 int serverCount = allList.size(); if (serverCount == 0) { return null; } // int index = chooseRandomInt(serverCount); //生成区间随机数 // server = upList.get(index); //从活着的服务中,随机获取一个 if (total<5){ server = upList.get(currentIndex); total++; }else { total = 0; currentIndex++; if (currentIndex>upList.size()){ currentIndex = 0; //当提供服务的人的执行次数大于活着的服务数量时,重置为0 } server = upList.get(currentIndex); //从或者的服务中来获取指定的服务 } if (server == null) { Thread.yield(); continue; } if (server.isAlive()) { return (server); } server = null; Thread.yield(); } return server; } protected int chooseRandomInt(int serverCount) { return ThreadLocalRandom.current().nextInt(serverCount); } @Override public Server choose(Object key) { return choose(getLoadBalancer(), key); } @Override public void initWithNiwsConfig(IClientConfig clientConfig) { // TODO Auto-generated method stub } } 注册到Spring容器中package com.sw.myrule; import com.netflix.loadbalancer.IRule; import com.netflix.loadbalancer.RoundRobinRule; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; /** * @Author suaxi * @Date 2020/12/29 16:12 */ @Configuration public class TestRule { @Bean public IRule myRule(){ return new MyRandomRule(); } } package com.sw.springcloud.config; import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate; /** * @Author suaxi * @Date 2020/12/28 22:15 */ @Configuration public class ConfigBean { //配置负载均衡实现RestTemplate //IRule //RoundRobinRule 轮询 //RandomRule 随机数 //AvailabilityFilteringRule 先过滤不可用的服务,对剩下的进行轮询 //RetryRule 先按照轮询获取服务,如果获取服务失败,则会在指定的时间内进行重试 @Bean @LoadBalanced //注册Ribbon public RestTemplate getRestTemplate(){ return new RestTemplate(); } } 开启自定义Ribbon注解package com.sw.springcloud; import com.sw.myrule.TestRule; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.ribbon.RibbonClient; /** * @Author suaxi * @Date 2020/12/28 22:29 */ @SpringBootApplication @EnableEurekaClient //在微服务启动的时候加载自定义的Ribbon类 @RibbonClient(name = "SPRINGCLOUD-PROVIDER-DEPT",configuration = TestRule.class) public class DeptConsumer_80 { public static void main(String[] args) { SpringApplication.run(DeptConsumer_80.class,args); } }
2020年12月30日
78 阅读
0 评论
0 点赞
2020-12-30
Eureka
Eureka1、什么是Eureka?Eureka是Netflix开发的服务发现框架,本身是一个基于REST的服务,主要用于定位运行在AWS域中的中间层服务,以达到负载均衡和中间层服务故障转移的目的。SpringCloud将它集成在其子项目spring-cloud-netflix中,以实现SpringCloud的服务发现功能。2、Eureka包含两个组件:Eureka Server和Eureka Client。Eureka Server提供注册服务Eureka Client是一个Java客户端,用于简化与Eureka Server的交互3、Eureka自我保护机制某时刻一个为服务不可用了,Eureka不会立刻清理该服务,依旧会对该服务的信息进行保存。一般情况下,EurekaServer与微服务实例之间存在心跳机制,节点默认90秒未收到微服务的心跳则会注销该实例;当EurekaServer在短时间内丢失过多的客户端,此时这个节点就会进入自我保护模式,保护服务注册表中的信息,不会注销任何微服务,直至故障恢复当节点收到的心跳重新恢复到阈值以上时,会自动退出自我保护机制在application.yml配置中可以添加eureka.server.enable-self-preservation = false禁用自我保护机制(不推荐)4、CAP理论C(Consistency):强一致性 A(Availability):可用性 P(Parition tolerance):分区容错性==一个分布式系统不可能同时满足一致性==NoSQL数据库分为CA、CP、AP三大类原则:CA:满足一致性、可用性,通常可扩展性较差CP:满足一致性,分区容错性的系统,通常性能不是特别高AP:满足可用性、分区容错性的系统,通常对一致性要求较低5、Zookeeper与EurekaZookeeper:(CP)当主节点因为网络故障或其他原因与节点失去联系时,剩余节点会进行leader选举,这个选举过程耗时较长,且在选举期间,整个集群都处于不可用状态Eureka:(AP)eureka各个节点都是平等的,只要有一个节点还在,就能保持服务注册与发现的可用性;如果在15分钟内超过85%的节点都没有正常的心跳,eureka就会认为客户端与注册中心出现了故障,会出现以下几种状况:不再从注册列表移除长时间没有收到心跳而应该过期的服务仍能接收新的服务注册与发现请求,但不会同步到其他节点上,以保证当前节点的可用性当网络稳定,故障恢复时,同步信息到其他EurekaServer节点
2020年12月30日
263 阅读
0 评论
0 点赞
2020-12-30
微服务
微服务1、什么是微服务?将传统的一站式应用,拆分为单个的服务,彻底去耦合,每一个微服务提供单个业务功能的服务,能够自行单独启动和销毁,拥有自己独立的数据库。2、微服务与微服务架构微服务强调服务的大小,它关注的是某一个点,即解决具体问题/提供对应服务的一个服务应用,类似于IDEA一个项目中的单个Moudel微服务架构强调架构模式,它提倡将单一应用程序划分成一组小的服务,服务之间互相协调,互相配合,且每个服务围绕着具体的业务进行构建,并且能被独立的部署到生产环境中。对具体的一个服务而言,应根据业务上下文,选择合适的语言,工具对其进行构建。3、现有的微服务解决方案(举例)Spring Cloud Netflix(一站式解决方案)API网关,Zuul组件Feign服务注册与发现:EurekaHystrix熔断机制Apache Dubbo Zookeeper第三方组件APIDubbo服务注册与发现:Zookeeper借助Hystrix熔断机制Spring Cloud Alibaba全家桶4、微服务优缺点优点:单一职责每个服务足够内聚,足够小,聚焦一个指定的业务功能或需求能够被2-5人的小团队单独开发耦合低,在开发或部署阶段都是独立的多语言开发易于和第三方集成,微服务允许容易且灵活的方式集成自动部署,通过持续集成工具,例如:jenkins、Hudson、bamboo微服务更多的是关注业务逻辑层面的代码,不会和前端混合每个微服务都有自己的存储能力,可以有自己的数据库,也可以有统一的数据库易于开发人员的理解,修改和维护……缺点:分布式系统较复杂多服务维护难度大、成本高系统部署依赖服务间通信成本数据一致性系统集成测试性能监控……微服务技术栈
2020年12月30日
65 阅读
0 评论
0 点赞
2020-12-28
服务注册发现
服务注册发现步骤:1、开启zookeeper服务2、提供者导入依赖配置注册中心的地址,服务发现名,要扫描的包在想要注册的服务类上增加(Dubbo包下的)@Service注解3、消费者导入依赖配置注册中心地址,服务名从远程注入服务(Dubbo包下的)@Reference注解1、开启zookeeper服务(以windows环境为例)2、通过maven命令打包dubbo,或者在github下载源码导入idea打包通过cmd命令java -jar dubbo-admin-0.0.1-SNAPSHOT.jar启动dubbo3、服务者Demo导入依赖(服务者和消费者需要的依赖一样)<!--Dubbo--> <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>2.7.3</version> </dependency> <!--zkClient--> <dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> <version>0.1</version> </dependency> <!--引入zookeeper--> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> <version>2.12.0</version> </dependency> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-recipes</artifactId> <version>2.12.0</version> </dependency> <dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.14</version> <!--排除slf4j-log4j12--> <exclusions> <exclusion> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> </exclusion> </exclusions> </dependency>application.yml配置(服务者)server: port: 8088 dubbo: application: name: provider-server registry: address: zookeeper://127.0.0.1:2181 scan: base-packages: com.sw.service Servicepackage com.sw.service; /** * @Author suaxi * @Date 2020/12/27 11:57 */ public interface TicketService { public String getTicket(); } package com.sw.service; import org.apache.dubbo.config.annotation.Service; import org.springframework.stereotype.Component; /** * @Author suaxi * @Date 2020/12/27 11:58 * zookeeper:服务注册与发现 */ @Service //Dubbo @Service注解可以被扫描到,项目一启动,服务就自动注册到注册中心 @Component //使用Dubbo后尽量用Component注解,Spring的Service注解导包时容易搞混 public class TicketServiceImpl implements TicketService{ @Override public String getTicket() { return "获得票一张!"; } } 4、消费者Demo导入pom.xml的依赖与服务者一样application.yml配置(消费者)server: port: 8089 dubbo: application: name: consumer-server registry: address: zookeeper://127.0.0.1:2181Servicepackage com.sw.service; /** * @Author suaxi * @Date 2020/12/27 11:57 */ public interface TicketService { public String getTicket(); } package com.sw.service; import org.apache.dubbo.config.annotation.Reference; import org.springframework.stereotype.Service; /** * @Author suaxi * @Date 2020/12/27 12:07 */ @Service //放到Spring容器中 public class UserService { //想要拿到provider-server的票,需要到注册中心拿 @Reference //引用,pom坐标,可以定义路径相同的接口名 TicketService ticketService; public void buyTicket(){ String ticket = ticketService.getTicket(); System.out.println("在注册中心拿到===>"+ticket); } } Junit测试类package com.sw; import com.sw.service.UserService; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class ConsumerServerApplicationTests { @Autowired private UserService userService; @Test public void consumerTest() { userService.buyTicket(); } } 5、Dubbo前端管理页面通过localhost:7001可以进入dubbo的管理员页面,账号密码都是root
2020年12月28日
99 阅读
0 评论
0 点赞
2020-12-28
Dubbo
Dubbo什么是分布式系统?分布式系统是若干个独立计算机的集合,这些计算机对用户来说就像是单个系统一样。RPCRPC(Remote Produce Call)指远程过程调用,是一种进程间的通信方式。如:有服务器A、服务器B,一个应用部署在A服务器上,数据、函数/方法等在服务器B上,现想通过A的应用调用B的数据,由于两者不在一个内存空间,不能直接调用,需通过网络来表达调用的语义和传达调用的数据。RPC的两个核心模块:通信、序列化Dubbo面向接口的远程方法调用,智能容错和负载均衡,服务自动注册和发现注:图片来源Apache Dubbo官网Provider:暴露服务的服务提供商,服务提供者在启动时,向注册中心注册自己提供的服务Consumer:调用远程服务的服务消费方,服务消费者在启动时,向注册中心订阅自己所需的服务,服务消费者,从提供者地址列表中,基于软负载均衡算法,选一台提供者进行调用,如果调用失败,再选另一台调用Registry:注册中心返回服务提供者地址列表给消费者,如果有变更,注册中心将基于长连接推送变更数据给消费者Monitor:服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次监控数据到统计中心
2020年12月28日
145 阅读
0 评论
0 点赞
1
...
3
4