当前位置: 首页 > wzjs >正文

做网站需要多少钱协会宣传网站开发方案

做网站需要多少钱,协会宣传网站开发方案,seo课程培训入门,百度地图开放平台大纲 1.参数限流的原理和源码 2.SentinelResource注解的使用和实现 2.SentinelResource注解的使用和实现 (1)SentinelResource注解的使用 (2)SentinelResource注解和实现 (1)SentinelResource注解的使用 一.引入Sentinel Spring Boot Starter依赖 <dependency><…

大纲

1.参数限流的原理和源码

2.@SentinelResource注解的使用和实现

2.@SentinelResource注解的使用和实现

(1)@SentinelResource注解的使用

(2)@SentinelResource注解和实现

(1)@SentinelResource注解的使用

一.引入Sentinel Spring Boot Starter依赖

<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-sentinel</artifactId><version>2.2.1.RELEASE</version>
</dependency>

二.为方法添加@SentinelResource注解

下面的代码为sayHello()方法添加了@SentinelResource注解,并指定了资源名称为sayHello以及熔断降级时的回调方法fallback()。这样在请求sayHello()方法后,就可以在Sentinel Dashboard上看到此资源,然后就可以针对此资源进行一系列的规则配置了。

@Service
public class MyService {@SentinelResource(value = "sayHello", fallback = "fallback")public String sayHello(String name) {return "Hello, " + name;}public String fallback(String name, Throwable throwable) {return "Fallback: " + name + ", reason: " + throwable.getMessage();}
}

(2)@SentinelResource注解和实现

利用Spring AOP拦截@SentinelResource注解,最后调用SphU.entry()方法来进行处理。

//Aspect for methods with {@link SentinelResource} annotation.
@Aspect
public class SentinelResourceAspect extends AbstractSentinelAspectSupport {//SentinelResource注解@Pointcut("@annotation(com.alibaba.csp.sentinel.annotation.SentinelResource)")public void sentinelResourceAnnotationPointcut() {}@Around("sentinelResourceAnnotationPointcut()")public Object invokeResourceWithSentinel(ProceedingJoinPoint pjp) throws Throwable {//获取方法Method originMethod = resolveMethod(pjp);//获取方法上的SentinelResource注解,有了这个注解,就可以获取到注解的各种属性值了SentinelResource annotation = originMethod.getAnnotation(SentinelResource.class);if (annotation == null) {//Should not go through here.throw new IllegalStateException("Wrong state for SentinelResource annotation");}//获取资源名称String resourceName = getResourceName(annotation.value(), originMethod);//获取资源类型EntryType entryType = annotation.entryType();int resourceType = annotation.resourceType();//创建一个Entry对象,通过SphU.entry(resourceName)将当前方法纳入Sentinel的保护体系//如果当前资源的调用未触发任何Sentinel规则,则正常执行被拦截的方法,否则将执行对应的限流、熔断降级等处理逻辑Entry entry = null;try {entry = SphU.entry(resourceName, resourceType, entryType, pjp.getArgs());return pjp.proceed();} catch (BlockException ex) {//发生异常时,通过反射执行在注解中设置的降级方法return handleBlockException(pjp, annotation, ex);} catch (Throwable ex) {Class<? extends Throwable>[] exceptionsToIgnore = annotation.exceptionsToIgnore();//The ignore list will be checked first.if (exceptionsToIgnore.length > 0 && exceptionBelongsTo(ex, exceptionsToIgnore)) {throw ex;}if (exceptionBelongsTo(ex, annotation.exceptionsToTrace())) {traceException(ex);return handleFallback(pjp, annotation, ex);}//No fallback function can handle the exception, so throw it out.throw ex;} finally {if (entry != null) {entry.exit(1, pjp.getArgs());}}  }
}//Some common functions for Sentinel annotation aspect.
public abstract class AbstractSentinelAspectSupport {...protected Object handleBlockException(ProceedingJoinPoint pjp, SentinelResource annotation, BlockException ex) throws Throwable {//Execute block handler if configured.Method blockHandlerMethod = extractBlockHandlerMethod(pjp, annotation.blockHandler(), annotation.blockHandlerClass());if (blockHandlerMethod != null) {Object[] originArgs = pjp.getArgs();//Construct args.Object[] args = Arrays.copyOf(originArgs, originArgs.length + 1);args[args.length - 1] = ex;return invoke(pjp, blockHandlerMethod, args);}//If no block handler is present, then go to fallback.return handleFallback(pjp, annotation, ex);}private Object invoke(ProceedingJoinPoint pjp, Method method, Object[] args) throws Throwable {try {if (!method.isAccessible()) {makeAccessible(method);}if (isStatic(method)) {return method.invoke(null, args);}return method.invoke(pjp.getTarget(), args);} catch (InvocationTargetException e) {//throw the actual exceptionthrow e.getTargetException();}}...
}


文章转载自:

http://A59AddhB.rccbt.cn
http://4FnIGclZ.rccbt.cn
http://kD1YioSW.rccbt.cn
http://keTkr9hh.rccbt.cn
http://d86SWszQ.rccbt.cn
http://wNojaQfk.rccbt.cn
http://Msg7zzA2.rccbt.cn
http://FmwonXqM.rccbt.cn
http://xDt5Ffd6.rccbt.cn
http://ZW2F60Py.rccbt.cn
http://etm919mk.rccbt.cn
http://y1mS7cH7.rccbt.cn
http://iG3tchDa.rccbt.cn
http://kFpLV51B.rccbt.cn
http://6MSWZ96Q.rccbt.cn
http://iKL5Tr3m.rccbt.cn
http://svKMG9Tk.rccbt.cn
http://HwY4on0O.rccbt.cn
http://0o6v1VTj.rccbt.cn
http://XhpjqaPE.rccbt.cn
http://doStPstv.rccbt.cn
http://bEJTdWBa.rccbt.cn
http://2wbpcfxp.rccbt.cn
http://BV8xmYfH.rccbt.cn
http://I8KEdOG6.rccbt.cn
http://n03G44cd.rccbt.cn
http://ketXBJgx.rccbt.cn
http://xIuA3MqN.rccbt.cn
http://qe9wbqKe.rccbt.cn
http://ejwBpwHX.rccbt.cn
http://www.dtcms.com/wzjs/709868.html

相关文章:

  • 网站建设最基础的是什么意思网站后台管理系统php
  • 网站域名收费标准网站提交搜索引擎后出现问题
  • 一流的铁岭做网站公司美发网站模板
  • 网站建设众包平台男生技能培训班有哪些
  • 网站宣传的劣势推广链接生成
  • 文字网站和图片网站哪个难做绍兴网站制作方案定制
  • 网站制作需要多少钱新闻网站做长尾词好还是单个词好
  • 毕节城乡建设局网站全国企业信息查询官网系统
  • 网站建设与管理下拉列表框给别人做网站多少钱
  • 深圳住房建筑网站白云区新闻
  • 网站建设要多少钱怎样wordpress内容页标签函数
  • 商会建设网站说明网页生成二维码源码
  • 网站开发需求范本汕头市住房和城乡建设局网站
  • 网站建设叁金手指花总8网站建设教程百度云
  • 网站空间续费一年多少钱阿里巴巴网站开发信在哪
  • 诛仙2官方网站西施任务怎么做做内部网站费用
  • 金山石化网站建设python整合网站开发技术
  • 钦州公司做网站东莞网站设地
  • 网站建设指标自己做的网站怎么接数据库
  • 外贸公司英文网站建设上海市建设市场管理信息平台网站
  • 企业网站主页 优帮云导购网站建设需求模版
  • 第一次做网站不知道陕西省建设网站 五大员过期
  • 数字博物馆网站建设wordpress完整教程
  • 粒子特效网站免费的做网站
  • 自动化发布 iis网站创建企业网站经过哪些步骤
  • 厦门网站建设方案报价手机开发者模式怎么调成高性能
  • 品牌型网站开发seo公司优化方案
  • 网站上做旅游卖家要学什么软件成都营销型网站公司电话
  • 深圳建设工程信息网站网络营销渠道可分为哪几种
  • 爱网站无法登录怎么回事现代装修风格效果图