Skip to content

Commit 930125c

Browse files
本文主要演示springboot整合alibaba sentinel各种降级规则遇到的问题
1 parent f97494e commit 930125c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

springboot-sentinel/src/main/java/com/github/lybgeek/sentinel/aspect/StatisticsExceptionCountAspect.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import com.alibaba.csp.sentinel.Tracer;
55
import com.alibaba.csp.sentinel.adapter.spring.webmvc.config.BaseWebMvcConfig;
66
import com.github.lybgeek.common.exception.BizException;
7+
import lombok.extern.slf4j.Slf4j;
78
import org.aspectj.lang.ProceedingJoinPoint;
9+
import org.aspectj.lang.annotation.AfterThrowing;
810
import org.aspectj.lang.annotation.Around;
911
import org.aspectj.lang.annotation.Aspect;
1012
import org.aspectj.lang.annotation.Pointcut;
@@ -31,6 +33,7 @@
3133
**/
3234
@Aspect
3335
@Component
36+
@Slf4j
3437
public class StatisticsExceptionCountAspect {
3538

3639
@Autowired
@@ -42,7 +45,13 @@ public void pointcut(){
4245

4346
}
4447

45-
@Around("pointcut()")
48+
@AfterThrowing(pointcut = "pointcut()",throwing = "ex")
49+
public void afterAfterThrowing(Throwable ex){
50+
log.info("statisticsExceptionCount...");
51+
traceException(ex);
52+
}
53+
54+
// @Around("pointcut()")
4655
public Object around(ProceedingJoinPoint pjp) {
4756
try {
4857
Object result = pjp.proceed();

0 commit comments

Comments
 (0)