javascript
SpringCloud学习一
文章目錄
- SpringCLoud
- 總覽
- 服務注冊/發現&注冊中心
- 1、Eureka
- 2、Consul
- 3、Zookeeper
- 服務接口調用
- OpenFeign
- 負載均衡
- Ribbon(蝴蝶結)
- 服務熔斷降級
- Hystrix(豪豬獸)
- 1、服務降級
- 2、服務熔斷
- 3、服務監控
- 服務網關
- 1、Gateway
- 路由轉發
- Filter
- 服務配置中心
- 實現:
- 動態刷新
- 消息總線
- Bus
- 廣播
- 定點通知
- 消息驅動
- Stream
SpringCLoud
總覽
參考鏈接
服務注冊/發現&注冊中心
1、Eureka
服務注冊(服務提供者)/發現(服務調用者)&注冊中心(服務中介)
-
服務注冊:
當 Eureka 客戶端向 Eureka Server 注冊時,它提供自身的元數據,比如IP地址、端口,運行狀況指示符URL,主頁等。
-
服務續約:
Eureka 客戶會每隔30秒(默認情況下)發送一次心跳來續約。通過續約來告知 Eureka Server 該 Eureka 客戶仍然存在,沒有出現問題。正常情況下,如果 Eureka Server 在90秒沒有收到 Eureka 客戶的續約,它會將實例從其注冊表中刪除。
-
服務下線
Eureka客戶端在程序關閉時向Eureka服務器發送取消請求。發送請求后,該客戶端實例信息將從服務器的實例注冊表中刪除。該下線請求不會自動完成,它需要調用以下內容:DiscoveryManager.getInstance().shutdownComponent();
-
服務剔除
在默認的情況下,當Eureka客戶端連續90秒(3個續約周期)沒有向Eureka服務器發送服務續約,即心跳,Eureka服務器會將該服務實例從服務注冊列表刪除,即服務剔除。
-
獲取注冊列表信息 Fetch Registries
Eureka 客戶端從服務器獲取注冊表信息,并將其緩存在本地 。 該注冊列表信息定期(每30秒鐘)更新一次。 在默認的情況下 Eureka 客戶端使用壓縮 JSON 格式來獲取注冊列表的信息。
-
架構圖
-
步驟
-
注冊中心
-
pom(版本隨父項目)
父項目
<!--spring cloud Hoxton.SR1--> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Hoxton.SR1</version><type>pom</type><scope>import</scope> </dependency>注冊中心
<!--eureka-server--> <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId> </dependency> -
yml
fetch-registry為true表示獲取注冊信息列表,如果該項目就是注冊中心,則為false表示不用去獲取。
eureka:instance:hostname: eureka7001.com #eureka服務端的實例名稱client:register-with-eureka: false #false表示不向注冊中心注冊自己。fetch-registry: false #false表示自己端就是注冊中心,我的職責就是維護服務實例,并不需要去檢索服務service-url:#集群指向其它eureka# defaultZone: http://eureka7002.com:7002/eureka/#單機就是7001自己defaultZone: http://eureka7001.com:7001/eureka/#server:#關閉自我保護機制,保證不可用服務被及時踢除#enable-self-preservation: false#eviction-interval-timer-in-ms: 2000此路徑下找到hosts文件C:\Windows\System32\drivers\etc,并增加一下信息,方便直接通過域名訪問
# springcloud-eureka 127.0.0.1 eureka7001.com 127.0.0.1 eureka7002.com -
主啟動類
@EnableEurekaServer注解開啟Eureka
@SpringBootApplication @EnableEurekaServer public class EurekaServerMain7001 {public static void main(String[] args) {SpringApplication.run(EurekaServerMain7001.class,args);} }
-
-
客戶端
-
pom
<!-- eureka-client --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency> -
yml
eureka:client:register-with-eureka: true #將自身注冊到eurekafetch-registry: trueservice-url:defaultZone: http://localhost:7001/eureka # http://eureka7001.com:7001/eureka/ 也可以# defaultZone: http://eureka7001.com:7001/eureka,http://eureka7002.com:7002/eureka # 集群版 -
啟動類
@EnableEurekaClient
@SpringBootApplication @EnableEurekaClient public class PaymentMain8001 {public static void main(String[] args) {SpringApplication.run(PaymentMain8001.class, args);} }
2、Consul
3、Zookeeper
服務接口調用
OpenFeign
OpenFeign 直接內置了 Ribbon。
RestTemplate是Spring提供的一個訪問Http服務的客戶端類 。例如以下例子,我們就能通過/judge路徑訪問到http://localhost:8081//service1
@Autowired private RestTemplate restTemplate; // 這里是提供者A的ip地址,但是如果使用了 Eureka 那么就應該是提供者A的名稱 privatestaticfinal String SERVICE_PROVIDER_A = "http://localhost:8081";@PostMapping("/judge") public boolean judge(@RequestBody Request request) {String url = SERVICE_PROVIDER_A + "/service1";return restTemplate.postForObject(url, request, Boolean.class); }使用有些麻煩。OpenFeign能做到向 域名和IP地址的映射一樣進行服務間的調用
-
實現
- 消費端
-
pom
<!--openfeign--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency> -
yml
將默認等待時間延長,默認為一秒,因為連接遠程服務器已經多個項目直接的調用容易造成超時。
#設置feign客戶端超時時間(OpenFeign默認支持ribbon) ribbon: #指的是建立連接所用的時間,適用于網絡狀況正常的情況下,兩端連接所用的時間ReadTimeout: 5000 #指的是建立連接后從服務器讀取到可用資源所用的時間ConnectTimeout: 5000 -
主啟動類
@SpringBootApplication @EnableFeignClients public class OrderFeignMain80 {public static void main(String[] args) {SpringApplication.run(OrderFeignMain80.class, args);} } -
service
@Component @FeignClient(value = "CLOUD-PAYMENT-SERVICE") public interface PaymentFeignService {@GetMapping(value = "/payment/get/{id}")public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id);@GetMapping(value = "/payment/feign/timeout")public String paymentFeignTimeout(); } -
Controller
Controller 就可以像原來調用 Service 層代碼一樣調用它了。
@RestController @Slf4j public class OrderFeignController {@Resourceprivate PaymentFeignService paymentFeignService;@GetMapping(value = "/consumer/payment/get/{id}")public CommonResult<Payment> getPaymentById(@PathVariable("id") Long id){return paymentFeignService.getPaymentById(id);}@GetMapping(value = "/consumer/payment/feign/timeout")public String paymentFeignTimeout(){// OpenFeign客戶端一般默認等待1秒鐘return paymentFeignService.paymentFeignTimeout();} } -
提供端
實現@FeignClient注解標注類的路徑映射即可
負載均衡
Ribbon(蝴蝶結)
它是在消費者端進行的負載均衡 。
- RoundRobinRule:輪詢策略。Ribbon默認采用的策略。若經過一輪輪詢沒有找到可用的provider,其最多輪詢 10 輪。若最終還沒有找到,則返回 null。(默認)
- RandomRule: 隨機策略,從所有可用的 provider 中隨機選擇一個。
- RetryRule: 重試策略。先按照 RoundRobinRule 策略獲取 provider,若獲取失敗,則在指定的時限內重試。默認的時限為 500 毫秒。
實現:
配置類
@Configuration public class ApplicationContextConfig {@Bean@LoadBalancedpublic RestTemplate getRestTemplate(){return new RestTemplate();} }注意:先啟動Eureka,再啟動提供端,再啟動消費端
自定義負載均衡算法
實現 IRule 接口
修改配置文件或者自定義 Java Config 類。
不能與啟動類在同級包,也不能在啟動類同級包的子包下。
以下啟動類在com.lx下
自定義負載均衡在com.myrule下
@Configuration public class MySelfRule {@Beanpublic IRule myRule(){return new RandomRule();//定義為隨機} }服務熔斷降級
Hystrix(豪豬獸)
Hystrix是一個庫,可通過添加等待時間容限和容錯邏輯來幫助您控制這些分布式服務之間的交互。Hystrix通過隔離服務之間的訪問點,停止服務之間的級聯故障并提供后備選項來實現此目的,所有這些都可以提高系統的整體彈性。
在微服務場景中,通常會有很多層的服務調用。如果一個底層服務出現問題,故障會被向上傳播給用戶。我們需要一種機制,當底層服務不可用時,可以阻斷故障的傳播。這就是斷路器的作用。他是系統服務穩定性的最后一重保障。
在springcloud中斷路器組件就是Hystrix。Hystrix也是Netflix套件的一部分。他的功能是,當對某個服務的調用在一定的時間內(默認10000ms),有超過一定次數(默認20次)并且失敗率超過一定值(默認50%),(更多詳情見HystrixCommandProperties類),該服務的斷路器會打開。返回一個由開發者設定的fallback。
fallback可以是另一個由Hystrix保護的服務調用,也可以是固定的值。fallback也可以設計成鏈式調用,先執行某些邏輯,再返回fallback。
Hystrix的作用
1、服務降級
情景:
實現:
pom
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix</artifactId> </dependency>主啟動
@SpringBootApplication @EnableEurekaClient @EnableCircuitBreaker public class PaymentHystrixMain8001 {public static void main(String[] args) {SpringApplication.run(PaymentHystrixMain8001.class,args);}/***此配置是為了服務監控而配置,與服務容錯本身無關,springcloud升級后的坑*ServletRegistrationBean因為springboot的默認路徑不是"/hystrix.stream",*只要在自己的項目里配置上下面的servlet就可以了*/@Beanpublic ServletRegistrationBean getServlet() {HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);registrationBean.setLoadOnStartup(1);registrationBean.addUrlMappings("/hystrix.stream");registrationBean.setName("HystrixMetricsStreamServlet");return registrationBean;} }service
/*** @Description: 正常訪問* @Param0: id**/ public String paymentInfo_OK(Integer id) {return "線程池: "+Thread.currentThread().getName()+" paymentInfo_OK,id: "+id+"\t"+"O(∩_∩)O哈哈~"; }/*** @Description: 超時訪問/訪問異常,2s* @Param0: id**/ @HystrixCommand(fallbackMethod = "paymentInfo_TimeOutHandler",commandProperties={@HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds",value="2000")}) public String paymentInfo_TimeOut(Integer id) {int timeSleep=3000;try { TimeUnit.MILLISECONDS.sleep(timeSleep); } catch (InterruptedException e) { e.printStackTrace(); }return "線程池: "+Thread.currentThread().getName()+" id: "+id+"\t"+"O(∩_∩)O哈哈~"+" 耗時(毫秒): "+timeSleep; } /*** @Description: 超時處理**/ public String paymentInfo_TimeOutHandler(Integer id) {return "線程池: "+Thread.currentThread().getName()+" 8001系統繁忙,請稍后再試,id: "+id+"\t"+"o(╥﹏╥)o"; } /*** @Description: 訪問異常* @Param0: id**/ @HystrixCommand(fallbackMethod = "paymentInfo_ExceptionHandler") public String paymentInfo_Exception(Integer id) {int i=10/0;return "線程池: "+Thread.currentThread().getName()+" id: "+id+"\t"+"O(∩_∩)O哈哈~"+" 結果 "+i; } /*** @Description: 異常處理**/ public String paymentInfo_ExceptionHandler(Integer id) {return "線程池: "+Thread.currentThread().getName()+" 8001運行報錯,請稍后再試,id: "+id+"\t"+"o(╥﹏╥)o"; }問題:
改善
在調用端controller類上加上@DefaultProperties注解,指定整個類的全局降級處理方法
@RestController @DefaultProperties(defaultFallback = "payment_Global_FallbackMethod") public class OrderOpenFeignController {@ResourcePaymentService paymentService;@ResourcePaymentHystrixService paymentHystrixService;@GetMapping("/consumer/payment/get/{id}")public CommonResult<Payment> getPayment(@PathVariable("id") Long id) {return paymentService.getPaymentByid(id);}@GetMapping("/consumer/payment/hystrix/ok/{id}")public String paymentInfo_OK(@PathVariable("id") Integer id){String result = paymentHystrixService.paymentInfo_OK(id);System.out.println("*****result: "+result);return result;}@GetMapping("/consumer/payment/hystrix/timeout/{id}")/* @HystrixCommand(fallbackMethod = "paymentTimeOutFallbackMethod",commandProperties = {@HystrixProperty(name="execution.isolation.thread.timeoutInMilliseconds",value="1500")})*///使用全局處理之后寫下面的注解,不加屬性代表使用默認的全局處理方法@HystrixCommandpublic String paymentInfo_TimeOut(@PathVariable("id") Integer id){String result = paymentHystrixService.paymentInfo_TimeOut(id);System.out.println("*****result: "+result);return result;}public String paymentTimeOutFallbackMethod(@PathVariable("id") Integer id){return "timeout";}// 下面是全局fallback方法public String payment_Global_FallbackMethod(){return "Global異常處理信息,請稍后再試,/(ㄒoㄒ)/~~";}}2、服務熔斷
類比保險絲達到最大服務訪問后,直接拒絕訪問,拉閘限電,然后調用服務降級的方法并返回友好提示 。
服務的降級->進而熔斷->恢復調用鏈路
實現:
? service
//=====服務熔斷 @HystrixCommand(fallbackMethod = "paymentCircuitBreaker_fallback",commandProperties = {@HystrixProperty(name = "circuitBreaker.enabled",value = "true"),// 是否開啟斷路器@HystrixProperty(name = "circuitBreaker.requestVolumeThreshold",value = "10"),// 請求次數@HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds",value = "10000"), // 時間窗口期@HystrixProperty(name = "circuitBreaker.errorThresholdPercentage",value = "60"),// 失敗率達到多少后跳閘 }) public String paymentCircuitBreaker(@PathVariable("id") Integer id) {if(id < 0){throw new RuntimeException("******id 不能負數");}String serialNumber = IdUtil.simpleUUID();return Thread.currentThread().getName()+"\t"+"調用成功,流水號: " + serialNumber; } public String paymentCircuitBreaker_fallback(@PathVariable("id") Integer id) {return "id 不能負數,請稍后再試,/(ㄒoㄒ)/~~ id: " +id; }測試
通過改變參數訪問,當使用負數訪問是會觸發服務降級,多次降級后服務會自動打開熔斷(表現為即使使用正數訪問仍然是降級處理),之后逐漸恢復正常處理。
3、服務監控
實現:
pom
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId> </dependency>yml
9001端口
主啟動類
@EnableHystrixDashboard
要求,所有提供服務端都添加actuator
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>此版本需要配置路徑,才能用一下圖片路徑訪問
@Beanpublic ServletRegistrationBean getServlet() {HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);registrationBean.setLoadOnStartup(1);registrationBean.addUrlMappings("/hystrix.stream");registrationBean.setName("HystrixMetricsStreamServlet");return registrationBean;}注意:每個顏色的數字對應右上方每個屬性,例如,綠色代表成功次數。
服務網關
-
網關職責:
<img src="https://gitee.com/jklixin/images/raw/master/cloud/aHR0cDovL2Nvcy5yYWluMTAyNC5jb20vbWFya2Rvd24vaW1hZ2UtMjAxOTEwMDgxNjAzMjUwMjEucG5n.jpg" alt="img" style="zoom: 50%;" />
-
網關分類與功能:
1、Gateway
為微服務架構提供一種簡單而有效的統一的API路由管理方式
-
實現
-
pom
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-gateway</artifactId> </dependency> -
yml
server:port: 9527 spring:application:name: cloud-gatewaycloud:gateway:discovery:locator:enabled: true #開啟從注冊中心動態創建路由的功能,利用微服務名進行路由routes:- id: payment_routh #路由的ID,沒有固定規則但要求唯一,建議配合服務名# uri: http://localhost:8001 #匹配后提供服務的路由地址uri: lb://cloud-payment-service #匹配后提供服務的路由地址predicates:- Path=/payment/** # 斷言,路徑相匹配的進行路由 eureka:instance:hostname: cloud-gateway-serviceclient: #服務提供者provider注冊進eureka服務列表內service-url:register-with-eureka: truefetch-registry: truedefaultZone: http://eureka7001.com:7001/eureka -
主啟動
@SpringBootApplication @EnableEurekaClient public class GatewayMain9527 {public static void main(String[] args) {SpringApplication.run(GatewayMain9527.class,args);} } -
測試:
通過端口9527訪問服務名為cloud-payment-service的服務,路徑匹配時訪問成功
路由轉發
時間匹配
Predicate 支持設置一個時間,在請求進行轉發的時候,可以通過判斷在這個時間之前或者之后進行轉發。
predicates:- After=2020-01-20T06:06:06+08:00[Asia/Shanghai]2020/01/20之后訪問才會進行轉發到對應的服務, Before 同理
Cookie匹配
Cookie Route Predicate 可以接收兩個參數,一個是 Cookie name , 一個是正則表達式,
predicates:- Cookie=ityouknow, kee.e測試:curl http://localhost:9527 --cookie “ityouknow=kee.e”,匹配成功
請求頭匹配
Header Route Predicate 和 Cookie Route Predicate 一樣,也是接收 2 個參數,一個 header 中屬性名稱和一個正則表達式,這個屬性值和正則表達式匹配則執行。
predicates:- Header=X-Request-Id, \d+測試1 curl http://localhost:9527 -H “X-Request-Id:1234” 匹配成功
測試2 curl http://localhost:9527 -H “X-Request-Id:sfsg” 匹配失敗
Host匹配
Host Route Predicate 接收一組參數,一組匹配的域名列表,這個模板是一個 ant 分隔的模板,用.號作為分隔符。它通過參數中的主機地址作為匹配規則。
predicates:- Host=**.ityouknow.com測試 curl http://localhost:9527 -H “Host: www.ityouknow.com” 匹配成功
請求方式匹配
predicates:- Method=GETcurl 默認是以 GET 的方式去請求
測試 curl -X POST http://localhost:9527 匹配失敗
請求參數匹配
- Query Route Predicate 支持傳入兩個參數,一個是屬性名一個為屬性值,屬性值可以是正則表達式。
只要求情中包含該屬性即可匹配
測試 curl localhost:9527?smile=x&id=2 匹配成功。
- 將 Query 的值以鍵值對的方式進行配置,這樣在請求過來時會對屬性值和正則進行匹配
當請求中包含 keep 屬性并且參數值是以 pu 開頭的長度為三位的字符串才會進行匹配和路由。
測試1 curl localhost:9527?keep=pub 匹配成功
測試2 curl localhost:9527?keep=pubx 匹配失敗
請求ip匹配
Predicate 也支持通過設置某個 ip 區間號段的請求才會路由,RemoteAddr Route Predicate 接受 cidr 符號 (IPv4 或 IPv6) 字符串的列表(最小大小為 1),例如 192.168.0.1/16 (其中 192.168.0.1 是 IP 地址,16 是子網掩碼)。
predicates:- RemoteAddr=192.168.1.1/24請求的遠程地址是 192.168.1.10,則此路由將匹配
組合匹配
- 需要滿足所有斷言條件才會被轉發
- 當滿足多個路由時。先匹配先轉發原則
Filter
下例中表示當含有uname屬性是允許訪問。
@Component public class FilterConfig implements GlobalFilter,Ordered{@Overridepublic Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {System.out.println("進入過濾器");String uname=exchange.getRequest().getQueryParams().getFirst("uname");if(uname==null){//請求路徑中沒有該屬性值System.out.println("拒絕訪問");exchange.getResponse().setStatusCode(HttpStatus.NOT_ACCEPTABLE);return exchange.getResponse().setComplete();}//存在,放行return chain.filter(exchange);}@Overridepublic int getOrder() {return 0;} }測試: http://localhost:9527/payment/lb?uname=z3 訪問成功
服務配置中心
為分布式系統中的外部配置提供服務器和客戶端支持。方便部署與運維。有客戶端、服務端。
服務端也稱分布式配置中心,是一個獨立的微服務應用,用來連接配置服務器并為客戶端提供獲取配置信息,加密/解密信息等訪問接口。
客戶端則是通過指定配置中心來管理應用資源,以及與業務相關的配置內容,并在啟動的時候從配置中心獲取和加載配置信息。默認采用 git,并且可以通過 git 客戶端工具來方便管理和訪問配置內容。
優點:
- 集中管理配置文件
- 不同環境不同配置,動態化的配置更新
- 運行期間,不需要去服務器修改配置文件,服務會想配置中心拉取自己的信息
- 配置信息改變時,不需要重啟即可更新配置信息到服務
- 配置信息以 rest 接口暴露
實現:
服務端
pom
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId></dependency>yml
spring:application:name: cloud-config-server #注冊進Eureka服務器的微服務名cloud:config:server:git:# uri: git@github.com:zzyybs/springcloud-config.git #GitHub上面的git倉庫名字uri: https://gitee.com/jklixin/springcloud-config.git #Gitee上面的git倉庫名字####搜索目錄search-paths:- springcloud-config####讀取分支label: master啟動類
@EnableConfigServer
@SpringBootApplication @EnableConfigServer public class ConfigMain3344 {public static void main(String[] args) {SpringApplication.run(ConfigMain3344.class,args);} }客戶端
pom
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId></dependency>bootstrap.yml
spring:application:name: cloud-config-clientcloud:config:lable: master name: config #需要從github上讀取的資源名稱,注意沒有yml后綴名profile: dev #本次訪問的配置項uri: http://localhost:3344 #配置服務端,本微服務啟動后先去找3344號服務,通過SpringCloudConfig獲取GitHub的服務地址controller
@RestController //@RefreshScope public class ConfigController {@Value("${config.info}")String info;@GetMapping("/configInfo")public String getConfigInfo(){return info;} }訪問方式:
/{application}/{profile}[/{label}]
/{application}-{profile}.yml
/{label}/{application}-{profile}.yml
/{application}-{profile}.properties
/{label}/{application}-{profile}.properties
問題: 更改gitee上的內容,服務端更新成功,但是客戶端并未更新成功
動態刷新
解決:
客戶端引入actuator依賴
暴露監控端點
# 暴露監控端點 management:endpoints:web:exposure:include: "*"@refreshScope業務類Controller修改
需要運維發送Post請求刷新3355
curl -X POST "http://localhost:3355/actuator/refresh"問題: 多個客戶端如何實現動態刷新
消息總線
Bus
Bus支持兩種消息代理:RabbitMQ和Kafka
廣播
實現
-
服務端
-
添加bus-amqp依賴
<!--添加消息總線RabbitMQ支持--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-bus-amqp</artifactId></dependency> -
配置rabbitmq相關屬性
#rabbitmq相關配置rabbitmq:host: 123.56.16.54port: 5672username: guestpassword: guest -
暴露刷新端口
# 暴露bus刷新的端點 management:endpoints:web:exposure:include: 'bus-refresh' -
客戶端
- 添加bus-amqp依賴
- 配置rabbitmq相關屬性
測試:
更改配置文件
刷新
http://localhost:3344/config-dev.yml 一致
http://localhost:3355/configInfo 不一致
發送請求刷新 curl -X POST “http://localhost:3344/actuator/bus-refresh”
刷新
http://localhost:3355/configInfo 一致
http://localhost:3366/configInfo 一致
定點通知
實現: 公式:http://localhost:3344/actutor/bus-refresh/{destination}
測試: curl -X POST “http://localhost:3344/actuator/bus-refresh/config-client:3355”
? http://localhost:3355/configInfo 一致
? http://localhost:3366/configInfo 不一致
消息驅動
Stream
屏蔽底層消息中間件的差異,降低切換成本,統一消息的編程模型
總結
以上是生活随笔為你收集整理的SpringCloud学习一的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 算法.动态规划 导航/数塔取数字问题
- 下一篇: javascript顺序点击文字验证