1.简述
Hystrix在donet中的应用案例说明极少且不完整,此案例可以直接使用,基于donet4
适用点:隔离,熔断,降级,来解决web在高并发下,对远程服务的高依赖可能引起的雪崩问题
可以自己到github下载源码使用, 注意:直接下载的部分源码有问题,本案例已经修复这些bug
2.下载组件
链接: https://pan.baidu.com/s/1BM9VX4Z5Htc1Zxxvf9-u1A
3.组件结构
WEB URL:http://localhost:9000/dashboard/
STREAM URL: http://127.0.0.1:38080/Hystrix/
4.业务web中引入全部核心组件和独立组件,新建
-------AtlasPublisher.cs--------
public class AtlasPublisher : IHystrixMetricsPublisher
{
CommandMetricObserver observer;
public AtlasPublisher()
{
var atlasCfg = new AtlasConfig("http://10.0.75.2", 7101);
observer = new CommandMetricObserver(atlasCfg);
observer.Run();
}
public IHystrixMetricsPublisherCommand GetMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, IHystrixCircuitBreaker circuitBreaker, IHystrixCommandProperties properties)
{
return new HystrixServoMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties);
}
public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
{
return new Dummy1();
}
public void Dispose()
{
if (observer != null)
observer.Stop();
obser
Hystrix在donet中的应用案例说明极少且不完整,此案例可以直接使用,基于donet4
适用点:隔离,熔断,降级,来解决web在高并发下,对远程服务的高依赖可能引起的雪崩问题
可以自己到github下载源码使用, 注意:直接下载的部分源码有问题,本案例已经修复这些bug
2.下载组件
链接: https://pan.baidu.com/s/1BM9VX4Z5Htc1Zxxvf9-u1A
3.组件结构
WEB URL:http://localhost:9000/dashboard/
STREAM URL: http://127.0.0.1:38080/Hystrix/
4.业务web中引入全部核心组件和独立组件,新建
-------AtlasPublisher.cs--------
public class AtlasPublisher : IHystrixMetricsPublisher
{
CommandMetricObserver observer;
public AtlasPublisher()
{
var atlasCfg = new AtlasConfig("http://10.0.75.2", 7101);
observer = new CommandMetricObserver(atlasCfg);
observer.Run();
}
public IHystrixMetricsPublisherCommand GetMetricsPublisherForCommand(HystrixCommandKey commandKey, HystrixCommandGroupKey commandGroupKey, HystrixCommandMetrics metrics, IHystrixCircuitBreaker circuitBreaker, IHystrixCommandProperties properties)
{
return new HystrixServoMetricsPublisherCommand(commandKey, commandGroupKey, metrics, circuitBreaker, properties);
}
public IHystrixMetricsPublisherThreadPool GetMetricsPublisherForThreadPool(HystrixThreadPoolKey threadPoolKey, HystrixThreadPoolMetrics metrics, IHystrixThreadPoolProperties properties)
{
return new Dummy1();
}
public void Dispose()
{
if (observer != null)
observer.Stop();
obser

本文介绍了如何在C#项目中使用Hystrix.NET库,通过实例展示了如何实现服务降级和熔断,并重点讲解了如何获取并展示类似于监控统计图的数据,以提升系统的容错性和稳定性。
最低0.47元/天 解锁文章
266

被折叠的 条评论
为什么被折叠?



