Created
November 17, 2016 01:55
-
-
Save chocotan/fe754204d8af39dfaf72faaf0f198edb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//原来的业务代码: | |
return yourService.exec(params); | |
//改成: | |
return new ServiceCommand(yourService, params).execute(); | |
public class ServiceCommand extends HystrixCommand{ | |
yourService; | |
params; | |
HystrixThreadPoolProperties.Setter A系统setter = HystrixThreadPoolProperties.Setter().withCoreSize(50).withMaxQueueSize(200).withQueueSizeRejectionThreshold(50); | |
HystrixCommandProperties.Setter A系统commandSetter = HystrixCommandProperties.Setter() | |
.withCircuitBreakerForceClosed(true).withExecutionTimeoutInMilliseconds(3000).withExecutionIsolationSemaphoreMaxConcurrentRequests(50); | |
B系统setter | |
B系统commandSetter | |
... | |
public ServiceCommand(yourService, params){ | |
super( | |
Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey(系统号)) | |
.andCommandKey(HystrixCommandKey.Factory.asKey(系统号)) | |
.andThreadPoolPropertiesDefaults(该系统对应的线程池配置) | |
.andCommandPropertiesDefaults(该系统对应的command配置) | |
); | |
this.yourService = yourService; | |
this.params = params; | |
} | |
@Override | |
protected Object run() { | |
return yourService.exec(params); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment