美文网首页
【十三】Spring Cloud Alibaba sentine

【十三】Spring Cloud Alibaba sentine

作者: lemonMT | 来源:发表于2019-04-09 19:28 被阅读0次

这个可以用来做流控,监控等,效果要比cloud 的 Hystrix效果要好很多

1.1 建立项目,加入POM的依赖

 <!--阿里巴巴流控组件-->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
        </dependency>

1.2 增加对应的配置文件

spring.application.name=demo-alibaba-springcloud-sentinel
server.port=8001

# sentinel dashboard
spring.cloud.sentinel.transport.dashboard=localhost:8080

1.3 代码中增加一个简单的接口

@RestController
public class SentinelController {



    @GetMapping("/get")
    public Object  test(){

        return "hello word";
    }
    
}

1.4 启动这个中间件程序 sentinel, 注意我们尽量使用和阿里巴巴cloud版本一致的sentinel

https://github.com/alibaba/Sentinel/releases

java -jar sentinel.jar

1.5 查看效果如下

image.png

在对应的地方和接口,配置限流即可。

相关文章

网友评论

      本文标题:【十三】Spring Cloud Alibaba sentine

      本文链接:https://www.haomeiwen.com/subject/jradpqtx.html