|
| 1 | +package com.monkey01.hystrixclient.controller; |
| 2 | + |
| 3 | +import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; |
| 4 | +import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty; |
| 5 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 6 | +import org.springframework.web.bind.annotation.RequestMethod; |
| 7 | +import org.springframework.web.bind.annotation.RestController; |
| 8 | + |
| 9 | +/** |
| 10 | + * @Author: feiweiwei |
| 11 | + * @Description: |
| 12 | + * @Created Date: 11:00 17/9/21. |
| 13 | + * @Modify by: |
| 14 | + */ |
| 15 | +@RestController |
| 16 | +public class TestController { |
| 17 | + @HystrixCommand(fallbackMethod = "error", commandProperties = { |
| 18 | + @HystrixProperty(name="execution.isolation.strategy", value = "THREAD"), |
| 19 | + @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "4000"), |
| 20 | + @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "10"), |
| 21 | + @HystrixProperty(name = "circuitBreaker.errorThresholdPercentage", value = "40") |
| 22 | + }, threadPoolProperties = { |
| 23 | + @HystrixProperty(name = "coreSize", value = "1"), |
| 24 | +// @HystrixProperty(name = "maximumSize", value = "5"), |
| 25 | + @HystrixProperty(name = "maxQueueSize", value = "10"), |
| 26 | + @HystrixProperty(name = "keepAliveTimeMinutes", value = "1000"), |
| 27 | + @HystrixProperty(name = "queueSizeRejectionThreshold", value = "8"), |
| 28 | + @HystrixProperty(name = "metrics.rollingStats.numBuckets", value = "12"), |
| 29 | + @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "1440") |
| 30 | + }) |
| 31 | + @RequestMapping(value = "/hello", method = RequestMethod.GET, produces = {"application/json;charset=UTF-8"}) |
| 32 | + public String hello(){ |
| 33 | + return "hello hystrix!"; |
| 34 | + } |
| 35 | + |
| 36 | + public String error() { |
| 37 | + return "hello error!"; |
| 38 | + } |
| 39 | + |
| 40 | +} |
0 commit comments