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

wordpress google 360信阳seo优化顾问

wordpress google 360,信阳seo优化顾问,国际机票网站建设,大连百度推广Spring Cloud项目为Netflix OSS Hystrix库提供了全面的支持。 之前我已经写过有关如何使用原始Hystrix库包装远程调用的文章。 在这里#xff0c;我将探讨如何将Hystrix与Spring Cloud结合使用 基本 实际上并没有什么大不了的#xff0c;这些概念仅在特定于Spring引导的增强… Spring Cloud项目为Netflix OSS Hystrix库提供了全面的支持。 之前我已经写过有关如何使用原始Hystrix库包装远程调用的文章。 在这里我将探讨如何将Hystrix与Spring Cloud结合使用 基本 实际上并没有什么大不了的这些概念仅在特定于Spring引导的增强中保留下来。 考虑一个简单的Hystrix命令该命令包含对Remote服务的调用 import agg.samples.domain.Message; import agg.samples.domain.MessageAcknowledgement; import agg.samples.feign.RemoteServiceClient; import com.netflix.hystrix.HystrixCommand; import com.netflix.hystrix.HystrixCommandGroupKey; import org.slf4j.Logger; import org.slf4j.LoggerFactory;public class RemoteMessageClientCommand extends HystrixCommandMessageAcknowledgement {private static final String COMMAND_GROUP demo;private static final Logger logger LoggerFactory.getLogger(RemoteMessageClientCommand.class);private final RemoteServiceClient remoteServiceClient;private final Message message;public RemoteMessageClientCommand(RemoteServiceClient remoteServiceClient, Message message) {super(HystrixCommandGroupKey.Factory.asKey(COMMAND_GROUP));this.remoteServiceClient remoteServiceClient;this.message message;}Overrideprotected MessageAcknowledgement run() throws Exception {logger.info(About to make Remote Call);return this.remoteServiceClient.sendMessage(this.message);}Overrideprotected MessageAcknowledgement getFallback() {return new MessageAcknowledgement(message.getId(), message.getPayload(), Fallback message);} } 这里没有与Spring相关的类此命令可以直接在基于Spring的项目中使用例如在控制器中以下列方式使用 RestController public class RemoteCallDirectCommandController {Autowiredprivate RemoteServiceClient remoteServiceClient;RequestMapping(/messageDirectCommand)public MessageAcknowledgement sendMessage(Message message) {RemoteMessageClientCommand remoteCallCommand new RemoteMessageClientCommand(remoteServiceClient, message);return remoteCallCommand.execute();} } Hystrix命令的行为自定义通常是通过NetflixOSS Archaius属性执行的但是Spring Cloud提供了一个桥梁使Spring定义的属性显示为Archaius属性这简而言之意味着我可以使用Spring特定的配置文件来定义我的属性自定义命令行为时将可见。 因此如果较早进行自定义则可以使用Archaius属性来表示HelloWorldCommand的行为如下所示 hystrix.command.HelloWorldCommand.metrics.rollingStats.timeInMilliseconds10000 hystrix.command.HelloWorldCommand.execution.isolation.strategyTHREAD hystrix.command.HelloWorldCommand.execution.isolation.thread.timeoutInMilliseconds1000 hystrix.command.HelloWorldCommand.circuitBreaker.errorThresholdPercentage50 hystrix.command.HelloWorldCommand.circuitBreaker.requestVolumeThreshold20 hystrix.command.HelloWorldCommand.circuitBreaker.sleepWindowInMilliseconds5000 这可以在Spring Cloud世界中以完全相同的方式在application.properties文件或application.yml文件中通过以下方式完成 hystrix:command:HelloWorldCommand:metrics:rollingStats:timeInMilliseconds: 10000execution:isolation:strategy: THREADthread:timeoutInMilliseconds: 5000circuitBreaker:errorThresholdPercentage: 50requestVolumeThreshold: 20sleepWindowInMilliseconds: 5000基于注释的方法 我个人更喜欢基于直接命令的方法但是在Spring世界中使用Hystrix的更好方法可能是使用基于hystrix-javanica的注释。 最好通过一个示例说明如何使用此注释。 这是包装在Hystrix命令中并带有注释的远程调用 import agg.samples.domain.Message; import agg.samples.domain.MessageAcknowledgement; import agg.samples.feign.RemoteServiceClient; import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service;Service public class RemoteMessageAnnotationClient {private final RemoteServiceClient remoteServiceClient;Autowiredpublic RemoteMessageAnnotationClient(RemoteServiceClient remoteServiceClient) {this.remoteServiceClient remoteServiceClient;}HystrixCommand(fallbackMethod defaultMessage, commandKey RemoteMessageAnnotationClient )public MessageAcknowledgement sendMessage(Message message) {return this.remoteServiceClient.sendMessage(message);}public MessageAcknowledgement defaultMessage(Message message) {return new MessageAcknowledgement(-1, message.getPayload(), Fallback Payload);}} 这些注解使用方面转换为幕后的常规Hystrix命令但很妙的是在Spring Cloud项目中没有使用该注解的仪式它只是工作而已。 与以前一样如果需要自定义行为则可以使用命令特定的属性来完成。 一个小问题是默认情况下命令名称是方法名称因此在我的示例中命令名称将是“ sendMessage”我已使用注释将其自定义为其他名称。 如果您有兴趣进一步探索该示例请参阅我的github项目 。 翻译自: https://www.javacodegeeks.com/2015/11/spring-cloud-support-hystrix.html
http://www.pierceye.com/news/516507/

相关文章:

  • 南京做网站费用做网站的服务器配置
  • 外贸用什么平台自建站较好门户网站盈利
  • 外包兼职做图的网站做视频网站用哪个模板
  • 全球购物网站大全百度网盟推广官方网站
  • 计算机网站维护建设深圳外网站建设
  • 贵州公明建设投资咨询有限公司官方网站小说网站开发对影成三人小说
  • 软件分享网站不一样的婚恋网站怎么做
  • 如何维护给做网站的客户公司变更名称和经营范围
  • 网站建设维护php建站最好的公司排名
  • 济南1951年建站wordpress 描述
  • 政务网站建设信息嵊州网站制作
  • 我的网站突然找不到网页了seo是啥意思
  • 黑河做网站的公司平面设计现在怎么样
  • 银川网站建站中国建设银行人力资源网站
  • 建设部考试中心网站用自己的ip怎么查看dw8建设的网站
  • 九江网站建设九江商标设计网页
  • 网站建设资格预审公告附近广告设计与制作门店电话
  • 百度权重站长工具网页制作工具哪些好用
  • 关键词整站优化公司网站店招用什么软件做的
  • 租车网站模版广州市网站建设 骏域
  • 关闭网站怎么不保存我做的更改人工智能专业
  • ui中有哪些做的好看的网站简单logo设计
  • 深圳大型网站设计公司校园 网站建设 知乎
  • 西部数码网站流量怎么充优化网站界面的工具
  • 街区网站建设东阳市住房和城乡建设局网站
  • 怎样建设网站是什么网站代码制作软件
  • 成华区微信网站建设计公司加盟
  • 找个男做那个视频网站好高端网站建设公司
  • 做网站 毕业设计广东手机网页制作
  • 沈阳口碑最好的男科医院seo排名优化什么意思