Spring Cloud构建微服务架构(三)断路器
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
package com.didispace.service;
|
||||
|
||||
import org.springframework.cloud.netflix.feign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@FeignClient(value = "compute-service", fallback = ComputeClientHystrix.class)
|
||||
public interface ComputeClient {
|
||||
|
||||
@RequestMapping(method = RequestMethod.GET, value = "/add")
|
||||
Integer add(@RequestParam(value = "a") Integer a, @RequestParam(value = "b") Integer b);
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.didispace.service;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@Component
|
||||
public class ComputeClientHystrix implements ComputeClient {
|
||||
|
||||
@Override
|
||||
public Integer add(@RequestParam(value = "a") Integer a, @RequestParam(value = "b") Integer b) {
|
||||
return -9999;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user