java 服务降级开关设计思路.docx

  1. 1、本文档共4页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
java 服务降级开关设计思路

java 服务降级开关设计思路java 服务屏蔽开关系统,可以手工降级服务,关闭服务基于spring AOP机制,可以在特殊情况下屏蔽相关service类的某些返回,并且支持定义默认返回结果,随机屏蔽某些异常服务。通过启动一个内置的http server来监听外部指令。对当前应用的影响。使用指南:1.在spring配置文件中添加如下,其中switch-service-pointcut是添加紧急情况下需要屏蔽的方法列表[java]view plaincopyprint?aop:config proxy-target-class=true/aop:config bean id=switchInteceptorclass=org.autoswitch.SwitchInteceptor /bean bean id=switch-service-pointcutclass=org.springframework.aop.support.JdkRegexpMethodPointcut property name=patterns list valueorg.autoswitch.test.*/value /list /property /bean aop:config aop:advisor advice-ref=switchInteceptor pointcut-ref=switch-service-pointcut/ /aop:config bean id=wwitchControlHttpServerclass=org.autoswitch.SwitchControlHttpServer init-method=init/bean bean id=testServiceclass=org.autoswitch.test.TestServiceImpl / bean id=testControllerclass=org.autoswitch.test.TestController / aop:config proxy-target-class=true/aop:configbean id=switchInteceptor class=org.autoswitch.SwitchInteceptor/beanbean id=switch-service-pointcut class=org.springframework.aop.support.JdkRegexpMethodPointcut property name=patterns list valueorg.autoswitch.test.*/value /list /property/beanaop:config aop:advisor advice-ref=switchInteceptor pointcut-ref=switch-service-pointcut//aop:configbean id=wwitchControlHttpServer class=org.autoswitch.SwitchControlHttpServer init-method=init/beanbean id=testService class=org.autoswitch.test.TestServiceImpl /bean id=testController class=org.autoswitch.test.TestController /例如下面的service,上面注释分别是在应用启动后手工屏蔽该服务调用,以后每次调用直接用参数的jsonResult反序列后返回, classmethod是具体到某个方法名称,status为open关闭该服务,close表示重新打开服务,jsonResult是mock返回结果的json串,如果是基本类型,则必须用ret作为key,其他list,bean之类的就直接用json串,type表示如果list有泛型的话则是返回的类完整类型;[java]view plaincopyprint?publicclass TestServiceImpl implements TestService{ //http://localhost:8080/control/a.htm?classmethod=org.autoswitch.test.TestServiceImpl.hellostatus=openjsonResult=1publicvoid hello(){ System.out.println(hello); } //http://localhost:8080/control/a.htm?clas

文档评论(0)

ipbohn97 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档