当前位置: 首页 > 知识库问答 >
问题:

在Spring-Boot应用程序中使用application.yaml配置hystrix命令属性

陶淳
2023-03-14
hystrix:
   command.StoreSubmission.execution.isolation.thread.timeoutInMilliseconds: 30000
   command.StoreSubmission.circuitBreaker.requestVolumeThreshold: 4
   command.StoreSubmission.circuitBreaker.sleepWindowInMilliseconds: 60000
   command.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000
   collapser.StoreSubmission.maxRequestsInBatch: 1
   collapser.StoreSubmission.requestCache.enabled: FALSE
   threadpool.StoreSubmission.coreSize: 30
   threadpool.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000
data: {"type":"HystrixCommand","name":"storeSubmission","group":"StoreSubmission","currentTime":1435941064801,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountCollapsedRequests":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackFailure":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1}

data: {"type":"HystrixThreadPool","name":"StoreSubmission","currentTime":1435941064801,"currentActiveCount":0,"currentCompletedTaskCount":35,"currentCorePoolSize":30,"currentLargestPoolSize":30,"currentMaximumPoolSize":30,"currentPoolSize":30,"currentQueueSize":0,"currentTaskCount":35,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":180000,"reportingHosts":1}
@EnableAutoConfiguration(exclude=MongoAutoConfiguration.class)
@EnableHystrix
@EnableHystrixDashboard

共有1个答案

徐智渊
2023-03-14

主要问题是,我使用groupKey值而不是commandKey值来定义属性。这些配置属性的wiki页面--https://github.com/netflix/hystrix/wiki/configuration#intro说明-

hystrix.command.HystrixCommandKey.execution.isolation.thread.timeoutInMilliseconds

用为CommandKey设置的值替换属性的HystrixCommandKey部分。

hystrix.threadpool.HystrixThreadPoolKey.coreSize

用为ThreadPoolKey设置的值替换属性的HystrixThreadPoolKey部分。

@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission")
public String storeSubmission(ReturnType returnType, InputStream is, String id) {
}
@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission", commandProperties = {
        @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000"),
        @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "4"),
        @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "60000"),
        @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") }, threadPoolProperties = {
        @HystrixProperty(name = "coreSize", value = "30"),
        @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") })
public String storeSubmission(ReturnType returnType, InputStream is, String id) {
}
 类似资料:
  • 我正在开发一个基于spring boot的web应用程序,希望使用log4j2作为记录器实现。 使用log4j2-spring.xml文件中定义的日志配置,一切都可以正常工作。 不起作用的地方:我想在log4j2-spring.xml文件中使用属性占位符,该占位符应该从用于配置Spring Boot的application.yml文件中定义的属性解析。

  • 到目前为止,我发现了两种在启动时配置spring boot应用程序的方法,一种使用< code>-D,另一种使用< code> - ,如下所示: 有时,第一个有效,有时第二个有效。正如开发人员所发现的那样,当以下示例中的 方法未给出 参数时,方法不起作用,但 起作用。 而今天,我在命令行配置日志,发现 但 工作。 以上可能有其他原因,可能< code > log back . configurat

  • 我正在开发一个Spring Boot应用程序,我使用application.properties配置db连接、服务器端口等。 例如,如何在application.properties中实现以下XML配置

  • 在Spring工具套件(eclipse的定制版本)中,有一个选项可以为同一个应用程序定义多个运行配置,然后运行它们。 例如,当测试一台Eureka服务器并运行具有不同端口和名称定义的同一应用程序的多个实例以检查注册时。 有人知道使用Spring和Java扩展以及Visual Studio代码定义类似运行配置的方法吗?

  • 我必须在Spring Boot应用程序的运行时更改自定义的spring属性(通过@ConfigurationProperties bean定义)。 使用Spring云配置有什么优雅的方法可以做到这一点吗? 我不想使用外部应用程序。git存储库中的属性(因为spring boot应用程序已交付给客户,我不想为他们每个人创建git存储库)。 我只想访问并更改本地应用程序。属性(类路径中的一个,位于sr

  • 我想知道,在SpringWeb应用程序中,是否有任何方法可以在没有Spring Boot的情况下使用SpringCloudConfig客户端。我想使用带有@Value注释的spring cloud config,我不喜欢在我的web应用程序中使用spring CloudServer rest api。我尝试了开发人员在spring CloudConfig Client中说的没有spring Boo