zoukankan      html  css  js  c++  java
  • alibaba-sentinel-1.8变化

    1. maven最新坐标
    <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
            </dependency>
            <dependency>
                <groupId>com.alibaba.cloud</groupId>
                <artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
            </dependency>
        </dependencies>
    
    1. 业务降级处理接口变化UrlBlockHandler ->BlockExceptionHandler
    2. 配置变化 WebCallbackManager被删除 只需要创建 BlockExceptionHandler 接口实现类即可实现自动配置
          @Configuration
    public class SentinelConfig {
    
    	@Bean
    	public BlockExceptionHandler sentinelBlockExceptionHandler() {
    		return (request, response, e) -> {
    			// 429 Too Many Requests
    			response.setStatus(429);
    
    			PrintWriter out = response.getWriter();
    			out.print("Oops, blocked by Sentinel: " + e.getClass().getSimpleName());
    			out.flush();
    			out.close();
    		};
    	}
    
    }
    
    1. 参考官方demo
  • 相关阅读:
    Java程序员从笨鸟到菜鸟全部博客目录
    Problem I
    Problem I
    Problem S
    Problem S
    Problem X
    Problem X
    Problem Q
    Problem Q
    Ellipse
  • 原文地址:https://www.cnblogs.com/cu-later/p/14136809.html
Copyright © 2011-2022 走看看