• hystrix实战之javanica


    spingboot2.0.3集成hystrix的,访问dashboard的另外一种方式:

    https://blog.csdn.net/qq_38455201/article/details/80783410

    这种方式不需要在application中添加下面的内容:

    第二种方式:

    使用下面的方式可以直接访问:http://localhost:8011/hystrix.stream

    @Bean
    public ServletRegistrationBean getServlet() {
    HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
    ServletRegistrationBean registrationBean = new ServletRegistrationBean(streamServlet);
    registrationBean.setLoadOnStartup(1);
    registrationBean.addUrlMappings("/hystrix.stream");
    registrationBean.setName("HystrixMetricsStreamServlet");
    return registrationBean;
    }

    自定义hystrix:

    不管什么方式,hystrix的返回类型和参数都要和方法一致,即使是自定义的hystrixCommand也是这样的。

    使用HystrixCommand,但是我们在开发中都已经分好了各种业务的servie,如何套入这个Hystrix?

    https://www.jianshu.com/p/77d95dc57584

    https://www.cnblogs.com/cowboys/p/7655829.html

    https://blog.csdn.net/sdmjhca/article/details/77948511

    https://segmentfault.com/a/1190000011006552

    https://www.jianshu.com/p/189e6675fb28

    大部分场景下使用默认属性即可,不需要配置那么多属性,更多的属性可以参考:https://github.com/Netflix/Hystrix/wiki/Configuration
     
    属性这么多紧接着就有一个问题:我们是否需要为每一个需要使用hystrix方法都定义一遍属性?
    比如:一个类中有很多方法,不能在每个方法都配置一遍相同的属性,容易造成配置代码的冗余;所以Javanica提供了@DefaultProperties注解,解释如下:
     
    @DefaultProperties是类(类型)级别的注释,允许默认命令属性,如groupKey,threadPoolKey,commandProperties,threadPoolProperties,ignoreExceptions和raiseHystrixExceptions。 
    使用此注解指定的属性,将在类中使用@HystrixCommand注解的方法中公用,除非某个方法明确使用相应的@HystrixCommand参数来指定这些属性。
  • 相关阅读:
    Java基础
    第11章 处理概括关系
    第10章 简化函数调用
    第9章 简化条件表达式
    第8章 重新组织数据(暂略)
    第7章 在对象之间搬移特性
    第6章 重新组织函数
    【剑指offer】57
    【每日一题-leetcode】45.跳跃游戏 ||
    【左神算法】随机+荷兰国旗优化版快排
  • 原文地址:https://www.cnblogs.com/fengli9998/p/9322995.html
Copyright © 2020-2023  润新知