软硬件环境:
1、IDEA
2、JDK1.8
3、Sentinel 1.7.0
4、Spring Boot 2.1.1.RELEASE
5、Spring Cloud Greenwich.SR3
6、Spring Cloud Alibaba 2.1.1.RELEASE
Sentinel Dashboard中的链路,与代码中的配置不相符
。
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 流控
*
* @author JustryDeng
* @date 2020/2/14 17:01
*/
@RestController
@RequiredArgsConstructor
public class FlowControlController {
private final TmpService tmpService;
@GetMapping("/hello")
public String ds() {
return "hello DengShuai";
}
@GetMapping("/hi")
public String jd() {
return "hi JustryDeng";
}
@GetMapping("/abc")
public String abc() {
return "DengShuai invoke " + tmpService.commonLogic();
}
@GetMapping("/xyz")
public String xyz() {
return "JustryDeng invoke " + tmpService.commonLogic();
}
@Component
public static class TmpService {
@SentinelResource(value = "common")
public String commonLogic() {
return "i am service logic";
}
}
}
面向未来微服务:熟练掌握Spring Cloud Alibaba
了解课程