日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 前端技术 > javascript >内容正文

javascript

深入了解SpringCloud Hystrix

發(fā)布時(shí)間:2024/1/17 javascript 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 深入了解SpringCloud Hystrix 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

雪崩效應(yīng)即在多個(gè)服務(wù)節(jié)點(diǎn)當(dāng)中,如果有一個(gè)服務(wù)不可用而這個(gè)不可用的服務(wù)導(dǎo)致整個(gè)應(yīng)用資源都耗在這里,進(jìn)而影響整個(gè)系統(tǒng)的崩潰。在分布式環(huán)境中,不可避免地會(huì)出現(xiàn)雪崩效應(yīng)。Hystrix是一個(gè)netflix實(shí)現(xiàn)了 circuit breaker pattern模式的庫(kù),它通過(guò)處理并發(fā)量,降低延遲故障和優(yōu)雅的容錯(cuò)處理來(lái)幫助您控制這些分布式服務(wù)之間的交互。Hystrix通過(guò)隔離服務(wù)之間的訪問(wèn)點(diǎn),停止跨服務(wù)的級(jí)聯(lián)故障和優(yōu)雅的降級(jí)來(lái)提高系統(tǒng)的整體彈性。

5.2.1 為什么需要Hystrix

hystrix的作用:

  • 通過(guò)第三方客戶(hù)端庫(kù)訪問(wèn)依賴(lài)項(xiàng)(通常是通過(guò)網(wǎng)絡(luò)),以保護(hù)和控制延遲和故障。
  • 防止雪崩效應(yīng)
  • 當(dāng)遇到的問(wèn)題 快速失敗并優(yōu)雅的恢復(fù)
  • 有效的進(jìn)行監(jiān)控與警告
  • 5.2.2 防止雪崩效應(yīng)

    Hystrix采用了如下方式來(lái)防止雪崩效應(yīng):

  • 在HystrixCommand或HystrixObservableCommand對(duì)象中封裝對(duì)外部系統(tǒng)(或“依賴(lài)項(xiàng)”)的所有調(diào)用,該對(duì)象通常在單獨(dú)的線(xiàn)程中執(zhí)行(這是命令模式的一個(gè)示例)。
  • 為每個(gè)依賴(lài)項(xiàng)維護(hù)一個(gè)小的線(xiàn)程池(或信號(hào)量); 如果它被填滿(mǎn)了,發(fā)送給該依賴(lài)項(xiàng)的請(qǐng)求將立即被拒絕,而不是排隊(duì)等待。
  • Hystrix會(huì)根據(jù)根據(jù)標(biāo)準(zhǔn)衡量是否成功、失敗(由客戶(hù)端拋出的異常)、超時(shí)和拒絕再一次的請(qǐng)求
  • 觸發(fā)斷路器,在一段時(shí)間內(nèi)停止對(duì)特定服務(wù)的所有請(qǐng)求,如果服務(wù)的錯(cuò)誤率超過(guò)閾值,則手動(dòng)或自動(dòng)停止。
  • 當(dāng)請(qǐng)求失敗、被拒絕、超時(shí)或短路時(shí),執(zhí)行回退邏輯。
  • 全方位的進(jìn)行監(jiān)控
  • 5.2.3 工作流程

    一、 構(gòu)建HystrixCommand或者HystrixObservableCommand對(duì)象

    第一步是構(gòu)造一個(gè)HystrixCommand或HystrixObservableCommand對(duì)象,表示您正在向依賴(lài)項(xiàng)發(fā)出的請(qǐng)求。HystrixCommand用于對(duì)一個(gè)依賴(lài)項(xiàng)產(chǎn)生獨(dú)立的響應(yīng),而HystrixObservableCommand拿到的是基于rxjava實(shí)現(xiàn)的響應(yīng)式結(jié)果observerable

    二、 執(zhí)行Command命令

    通過(guò)使用Hystrix命令對(duì)象的以下四種方法之一(前兩種方法僅適用于簡(jiǎn)單的HystrixCommand對(duì)象,不適用于HystrixObservableCommand),有四種方法可以執(zhí)行命令:

    • execute:阻塞的,可以從依賴(lài)項(xiàng)返回單個(gè)結(jié)果(或者在出現(xiàn)錯(cuò)誤時(shí)拋出異常)
    • queue: 從依賴(lài)項(xiàng)返回Future對(duì)象
    • observer:訂閱依賴(lài)項(xiàng)返回的結(jié)果,并返回復(fù)制該源頭Observable做為返回值對(duì)象
    • toObservable: 返回Observable對(duì)象,只有訂閱它的時(shí)候才會(huì)執(zhí)行hystrix command命令

    三、 查看緩存中是否有響應(yīng)結(jié)果

    如果開(kāi)啟了緩存,并且緩存中有針對(duì)于本次請(qǐng)求結(jié)果的緩存,那么將會(huì)讀取緩存中的值

    四、 斷路器是否打開(kāi)

    當(dāng)執(zhí)行命令時(shí),Hystrix會(huì)檢查斷路器是否打開(kāi)。如果斷路器的狀態(tài)是open或者tripped,那么Hystrix不會(huì)執(zhí)行相關(guān)命令,它會(huì)路由至第8步。如果斷路器沒(méi)有打開(kāi)則會(huì)執(zhí)行第5步

    五、 信號(hào)量/隊(duì)列/線(xiàn)程池是否填滿(mǎn)

    如果與命令關(guān)聯(lián)的線(xiàn)程池和隊(duì)列或信號(hào)量已經(jīng)滿(mǎn)了,那么Hystrix將不會(huì)執(zhí)行命令,它會(huì)立即路由到(8)進(jìn)行回退的操作。

    六、 HystrixObservableCommand.construct() or HystrixCommand.run()

    Hystrix通過(guò)調(diào)用如下方法進(jìn)行對(duì)依賴(lài)項(xiàng)的請(qǐng)求:

    • HystrixCommand.run()— 返回單獨(dú)的結(jié)果響應(yīng)
    • HystrixObservableCommand.construct()— 返回一個(gè)Observable對(duì)象

    如果run()或construct()方法超過(guò)命令的超時(shí)值,線(xiàn)程將拋出TimeoutException(如果命令本身不在自己的線(xiàn)程中運(yùn)行,則單獨(dú)的計(jì)時(shí)器線(xiàn)程將拋出該異常)。在這種情況下,Hystrix將響應(yīng)傳遞到步驟8來(lái)獲取回退,如果最終返回值run()或construct()方法沒(méi)有取消/中斷,它將丟棄。

    七、 計(jì)算斷路的健康值

    Hystrix向斷路器報(bào)告成功、故障、拒絕和超時(shí)等信息,斷路器維護(hù)一組動(dòng)態(tài)計(jì)數(shù)器,用于計(jì)算統(tǒng)計(jì)數(shù)據(jù)。它使用這些統(tǒng)計(jì)數(shù)據(jù)來(lái)確定電路什么時(shí)候應(yīng)該“跳閘”,如果已經(jīng)跳閘,它會(huì)短路任何后續(xù)請(qǐng)求,直到恢復(fù)周期結(jié)束,在此期間,它會(huì)在第一次檢查某些健康檢查后再次關(guān)閉電路

    八、 調(diào)用fallback方法

    當(dāng)Command命令執(zhí)行失敗時(shí),Hystrix會(huì)嘗試進(jìn)行回滾的操作,常見(jiàn)的失敗可原因如下:

    • construct() or run() 拋出異常時(shí)
    • 當(dāng)斷路器被打開(kāi)時(shí)
    • 線(xiàn)程、隊(duì)列或者信號(hào)量充滿(mǎn)時(shí)
    • commnad執(zhí)行超時(shí)

    九、 成功的進(jìn)行響應(yīng)

    5.2.4 跳閘原理

    電路開(kāi)閉的方式如下:

    一、 當(dāng)斷路器滿(mǎn)足某個(gè)閥值

    HystrixCommandProperties.circuitBreakerRequestVolumeThreshold()

    二、 當(dāng)錯(cuò)誤百分比超過(guò)某個(gè)閥值

    HystrixCommandProperties.circuitBreakerErrorThresholdPercentage()

    三、 而后斷路器有關(guān)—>開(kāi)

    四、當(dāng)斷路器打開(kāi)時(shí),所有的請(qǐng)求都會(huì)進(jìn)行短路操作,最常見(jiàn)的方式就是執(zhí)行fallback方法
    在一定時(shí)間以后,我們可以通過(guò)HystrixCommandProperties.circuitBreakerSleepWindowInMilliseconds()來(lái)設(shè)置此值。下一個(gè)請(qǐng)求會(huì)被放行(此時(shí)斷路器狀態(tài)是half-open),如果這次請(qǐng)求失敗了,仍會(huì)打開(kāi)斷路器。如果成功了,則斷路器進(jìn)行關(guān)閉

    5.2.5 隔離策略

    5.2.5.1 線(xiàn)程組隔離

    客戶(hù)機(jī)在單獨(dú)的線(xiàn)程上執(zhí)行。這將它們與調(diào)用線(xiàn)程(Tomcat線(xiàn)程池)隔離開(kāi)來(lái),以便調(diào)用者可以“避開(kāi)”耗時(shí)太長(zhǎng)的依賴(lài)項(xiàng)調(diào)用。官方推薦使用這種方式進(jìn)行服務(wù)與依賴(lài)之間的隔離,官方解釋的好處如下:

    • The application is fully protected from runaway client libraries. The pool for a given dependency library can fill up without impacting the rest of the application.
    • The application can accept new client libraries with far lower risk. If an issue occurs, it is isolated to the library and doesn’t affect everything else.
    • When a failed client becomes healthy again, the thread pool will clear up and the application immediately resumes healthy performance, as opposed to a long recovery when the entire Tomcat container is overwhelmed.
    • If a client library is misconfigured, the health of a thread pool will quickly demonstrate this (via increased errors, latency, timeouts, rejections, etc.) and you can handle it (typically in real-time via dynamic properties) without affecting application functionality.
    • If a client service changes performance characteristics (which happens often enough to be an issue) which in turn cause a need to tune properties (increasing/decreasing timeouts, changing retries, etc.) this again becomes visible through thread pool metrics (errors, latency, timeouts, rejections) and can be handled without impacting other clients, requests, or users.
    • Beyond the isolation benefits, having dedicated thread pools provides built-in concurrency which can be leveraged to build asynchronous facades on top of synchronous client libraries (similar to how the Netflix API built a reactive, fully-asynchronous Java API on top of Hystrix commands).

    我認(rèn)為其最主要的優(yōu)點(diǎn)就是各個(gè)服務(wù)模塊的“獨(dú)立性”,不依賴(lài)與容器中(tomcat)的線(xiàn)程組,出了問(wèn)題可以把風(fēng)險(xiǎn)降到最低同時(shí)也可以快速恢復(fù)。當(dāng)然其主要缺點(diǎn)是增加了計(jì)算開(kāi)銷(xiāo)。每個(gè)命令執(zhí)行都涉及到在單獨(dú)的線(xiàn)程上運(yùn)行命令所涉及的排隊(duì)、調(diào)度和上下文切換。不過(guò)官方?jīng)Q定接受這種開(kāi)銷(xiāo)的成本以換取它所提供的好處,他們認(rèn)為這種成本和性能影響不大。線(xiàn)程組隔離依賴(lài)的示例圖如下:

    5.2.5.2 信號(hào)量隔離

    信號(hào)量隔離,通常通過(guò)設(shè)置一個(gè)值來(lái)限制針對(duì)一項(xiàng)依賴(lài)的并發(fā)請(qǐng)求數(shù)目,這種方式可以允許不適用線(xiàn)程池的方式下降低負(fù)載量,如果您信任客戶(hù)端并且只希望減少負(fù)載,那么可以使用這種方法。一旦達(dá)到限制閥值,信號(hào)量拒絕其他線(xiàn)程的請(qǐng)求,但是填充信號(hào)量的線(xiàn)程不能離開(kāi)。

    如果使用ThreadLocal綁定變量或傳遞時(shí),一定要使用信號(hào)量的隔離方式

    5.2.6 單獨(dú)使用Hystrix示例

    package com.iteng.springcloud.hystrix;import com.netflix.hystrix.*;public class FirstHystrixExample extends HystrixCommand<String> {public FirstHystrixExample() {super(Setter. withGroupKey(HystrixCommandGroupKey.Factory.asKey(FirstHystrixExample.class.getSimpleName())).andCommandKey(HystrixCommandKey.Factory.asKey("test")). andThreadPoolPropertiesDefaults(HystrixThreadPoolProperties.Setter().withCoreSize(30)). andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationStrategy(HystrixCommandProperties.ExecutionIsolationStrategy.SEMAPHORE)).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionTimeoutInMilliseconds(1000)).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withExecutionIsolationSemaphoreMaxConcurrentRequests(1)).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withFallbackIsolationSemaphoreMaxConcurrentRequests(200)).andCommandPropertiesDefaults(HystrixCommandProperties.Setter().withCircuitBreakerEnabled(true)));}@Overrideprotected String run() throws Exception {// Thread.sleep(30000);return "hello";//return "hello";}@Overrideprotected String getFallback() {return "error msg...";}}

    關(guān)于Hystrix的相關(guān)配置請(qǐng)參考官網(wǎng):地址 ,這里需要指定hystrix的組和commandkey,我們可以通過(guò)以下方式來(lái)做:

    Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(FirstHystrixExample.class.getSimpleName())).andCommandKey(HystrixCommandKey.Factory.asKey("test"))

    在這里我們可以指定類(lèi)名為組,方法名為key。利用動(dòng)態(tài)代理來(lái)實(shí)現(xiàn)HystrixCommand

    調(diào)用示例:

    static void execute() {FirstHystrixExample firstHystrixExample = new FirstHystrixExample();System.out.println(firstHystrixExample.execute());}static void future() {FirstHystrixExample firstHystrixExample = new FirstHystrixExample();Future<String> future = firstHystrixExample.queue();try {String s = future.get(2, TimeUnit.SECONDS);System.out.println(s);} catch (Exception e) {e.printStackTrace();}}static void observer() {FirstHystrixExample firstHystrixExample = new FirstHystrixExample();firstHystrixExample.observe().subscribeOn(Schedulers.newThread()).subscribe(s -> System.out.println(Thread.currentThread().getName() + ":" + s));}

    5.2.7 SpringCloud集成Hystrix

    在SpringCloud中添加Hystrix的支持,我們需要在maven或者gradle里添加groupId為org.springframework.cloud,AffactId為spring-cloud-starter-netflix-hystrix的依賴(lài)。代碼示例如下:

    @SpringBootApplication@EnableCircuitBreakerpublic class Application {public static void main(String[] args) {new SpringApplicationBuilder(Application.class).web(true).run(args);}}@Componentpublic class StoreIntegration {@HystrixCommand(fallbackMethod = "defaultStores")public Object getStores(Map<String, Object> parameters) {//do stuff that might fail}public Object defaultStores(Map<String, Object> parameters) {return /* something useful */;}}

    其中SpringCloud在這里會(huì)把@HystrixCommand標(biāo)注的方法包裝成代理對(duì)象連接至Hystrix circuit breaker,Hystrix斷路保護(hù)器會(huì)計(jì)算什么時(shí)候開(kāi)閉。

    5.2.7.1 源碼分析

    我們可以來(lái)看一下它的源碼:

    在spring-cloud-netflix-core-2.0.1.RELEASE.jar中的META-INF/spring.factories里有如下配置:

    org.springframework.boot.autoconfigure.EnableAutoConfiguration=\org.springframework.cloud.netflix.hystrix.HystrixAutoConfiguration,\org.springframework.cloud.netflix.hystrix.security.HystrixSecurityAutoConfigurationorg.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker=\org.springframework.cloud.netflix.hystrix.HystrixCircuitBreakerConfiguration

    那么在HystrixCircuitBreakerConfiguration當(dāng)中可以看到如下實(shí)現(xiàn):

    /** Copyright 2013-2017 the original author or authors.** Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at** http://www.apache.org/licenses/LICENSE-2.0** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.* See the License for the specific language governing permissions and* limitations under the License.*/package org.springframework.cloud.netflix.hystrix;import org.apache.catalina.core.ApplicationContext;import org.springframework.beans.factory.DisposableBean;import org.springframework.cloud.client.actuator.HasFeatures;import org.springframework.cloud.client.actuator.NamedFeature;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import com.netflix.hystrix.Hystrix;import com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect;/*** @author Spencer Gibb* @author Christian Dupuis* @author Venil Noronha*/@Configurationpublic class HystrixCircuitBreakerConfiguration {@Beanpublic HystrixCommandAspect hystrixCommandAspect() {return new HystrixCommandAspect();}@Beanpublic HystrixShutdownHook hystrixShutdownHook() {return new HystrixShutdownHook();}@Beanpublic HasFeatures hystrixFeature() {return HasFeatures.namedFeatures(new NamedFeature("Hystrix", HystrixCommandAspect.class));}// ...省略部分代碼/*** {@link DisposableBean} that makes sure that Hystrix internal state is cleared when* {@link ApplicationContext} shuts down.*/private class HystrixShutdownHook implements DisposableBean {@Overridepublic void destroy() throws Exception {// Just call Hystrix to reset thread pool etc.Hystrix.reset();}}}

    在這里我們可以看到創(chuàng)建了一個(gè)HystrixCommandAspect的切面。在切面里有幾行關(guān)鍵的代碼:

    //定義尋找@HystrixCommand的切點(diǎn)@Pointcut("@annotation(com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand)")public void hystrixCommandAnnotationPointcut() {}@Pointcut("@annotation(com.netflix.hystrix.contrib.javanica.annotation.HystrixCollapser)")public void hystrixCollapserAnnotationPointcut() {}//環(huán)繞通知@Around("hystrixCommandAnnotationPointcut() || hystrixCollapserAnnotationPointcut()")public Object methodsAnnotatedWithHystrixCommand(final ProceedingJoinPoint joinPoint) throws Throwable {//根據(jù)切點(diǎn)找到對(duì)應(yīng)的執(zhí)行方法Method method = getMethodFromTarget(joinPoint);Validate.notNull(method, "failed to get method from joinPoint: %s", joinPoint);//如果方法上@HystrixCommand與@HystrixCollapser則扔出異常if (method.isAnnotationPresent(HystrixCommand.class) && method.isAnnotationPresent(HystrixCollapser.class)) {throw new IllegalStateException("method cannot be annotated with HystrixCommand and HystrixCollapser " +"annotations at the same time");}/*根據(jù)Joinpoint切點(diǎn)拿到MetaHolder,該類(lèi)封裝了與Hystrix相關(guān)的要素,如配置等根據(jù)metaHolder拿到HystrixInvokable對(duì)象,該對(duì)象定義了Hystrix的執(zhí)行規(guī)范*/MetaHolderFactory metaHolderFactory = META_HOLDER_FACTORY_MAP.get(HystrixPointcutType.of(method));MetaHolder metaHolder = metaHolderFactory.create(joinPoint);HystrixInvokable invokable = HystrixCommandFactory.getInstance().create(metaHolder);ExecutionType executionType = metaHolder.isCollapserAnnotationPresent() ?metaHolder.getCollapserExecutionType() : metaHolder.getExecutionType();Object result;try {if (!metaHolder.isObservable()) {//執(zhí)行hystrix的Commandresult = CommandExecutor.execute(invokable, executionType, metaHolder);} else {//通過(guò)Observable的方式執(zhí)行result = executeObservable(invokable, executionType, metaHolder);}} catch (HystrixBadRequestException e) {throw e.getCause() != null ? e.getCause() : e;} catch (HystrixRuntimeException e) {throw hystrixRuntimeExceptionToThrowable(metaHolder, e);}return result;}

    5.2.7.2 Hystrix傳播ThreadLocal

    如果我們想傳播ThreadLocal至@HystrixCommand中,只有設(shè)置默認(rèn)策略為semaphore才可以,因?yàn)樵谀J(rèn)情況下,Hystrix隔離策略是線(xiàn)程級(jí)別的,因此調(diào)用run方法時(shí)已經(jīng)是Hystrix單獨(dú)維護(hù)的線(xiàn)程了,示例:

    package com.iteng.springcloud.hystrix.service;import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.PathVariable;import org.springframework.web.bind.annotation.RestController;@RestControllerpublic class HystrixService {private ThreadLocal<String> threadLocal = new ThreadLocal<>();@Autowiredprivate HystrixService hystrixService;@HystrixCommand(fallbackMethod = "fallback")@GetMapping("/sleep/{value}")public String index(@PathVariable Integer value) {String r = threadLocal.get();return Thread.currentThread().getName() + ":" + r;}@GetMappingpublic String test() {threadLocal.set("test");return hystrixService.index(1);}public String fallback(Integer value) {return "error msg...";}}

    另外我們可以通過(guò)擴(kuò)展HystrixConcurrencyStrategy的方式來(lái)處理ThreadLocal的問(wèn)題,在這里官方明確的告訴我們這個(gè)辦法來(lái)解決:

    /*** Provides an opportunity to wrap/decorate a {@code Callable<T>} before execution.* <p>* This can be used to inject additional behavior such as copying of thread state (such as {@link ThreadLocal}).* <p>* <b>Default Implementation</b>* <p>* Pass-thru that does no wrapping.* * @param callable* {@code Callable<T>} to be executed via a {@link ThreadPoolExecutor}* @return {@code Callable<T>} either as a pass-thru or wrapping the one given*/public <T> Callable<T> wrapCallable(Callable<T> callable) {return callable;}

    使用示例:

    package com.iteng.springcloud.hystrix.concurrencystrategy;import com.iteng.springcloud.hystrix.FirstHystrixExample;import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;import java.util.concurrent.Callable;public class TestConcurrencyStrategy extends HystrixConcurrencyStrategy {@Overridepublic <T> Callable<T> wrapCallable(Callable<T> callable) {return new Callable<T>() {@Overridepublic T call() throws Exception {FirstHystrixExample.test.set("333");return callable.call();}};}}

    由于默認(rèn)情況下Hystrix加載HystrixProperties默認(rèn)是用ServiceLoader,具體可見(jiàn)(HystrixPlugins)因此需創(chuàng)建META-INF/services/com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy文件里面做如下配置:

    com.iteng.springcloud.hystrix.concurrencystrategy.TestConcurrencyStrategy

    那么改造5.2.6的示例:

    package com.iteng.springcloud.hystrix;import com.netflix.hystrix.*;import com.netflix.hystrix.strategy.concurrency.HystrixConcurrencyStrategy;import java.util.concurrent.Callable;public class FirstHystrixExample extends HystrixCommand<String> {//....省略部分代碼...public static ThreadLocal<String> test =new ThreadLocal<>();// .....@Overrideprotected String run() throws Exception {System.out.println(Thread.currentThread().getName()+":"+test.get());return "hello";}}

    那么在SpringCloud中我們可以將TestConcurrencyStrategy配置為一個(gè)bean就可以了

    5.2.7.3 健康信息

    hystrix提供了對(duì)健康信息的檢查,我們可以通過(guò)/health端點(diǎn)進(jìn)行有效的監(jiān)控,例如:

    {"hystrix": {"openCircuitBreakers": ["StoreIntegration::getStoresByLocationLink"],"status": "CIRCUIT_OPEN"},"status": "UP"}

    總結(jié)

    以上是生活随笔為你收集整理的深入了解SpringCloud Hystrix的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

    如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。