Hystrix 源码解读

return factories.toArray(new String[factories.size()]);

}

复制代码

image.png

现在知道对应配置是怎么自动读取的吧!

相关源码分析


image.png

image.png

核心逻辑com.netflix.hystrix.contrib.javanica.aop.aspectj.HystrixCommandAspect#methodsAnnotatedWithHystrixCommand

@Around(“hystrixCommandAnnotationPointcut() || hystrixCollapserAnnotationPointcut()”)

public Object methodsAnnotatedWithHystrixCommand(final ProceedingJoinPoint joinPoint) throws Throwable {

Method method = getMethodFromTarget(joinPoint);

Validate.notNull(method, “failed to get method from joinPoint: %s”, joinPoint);

if (method.isAnnotationPresent(HystrixCommand.class) && method.isAnnotationPresent(HystrixCollapser.class)) {

throw new IllegalStateException("method cannot be annotated with HystrixCommand and HystrixCollapser " +

“annotations at the same time”);

}

MetaHolderFactory metaHolderFactory = META_HOLDER_FACTORY_MAP.get(HystrixPointcutType.of(method));

MetaHolder metaHolder = metaHolderFactory.create(joinPoint);

HystrixInvokable invokable = HystrixCommandFactory.getInstance().create(metaHolder);

ExecutionType executionType = metaHolder.isCollapserAnnotationPresent() ?

metaHolder.getCollapserExecutionType() : metaHolder.getExecutionType();

Object result;

try {

if (!metaHolder.isObservable()) {

result = CommandExecutor.execute(invokable, executionType, metaHolder);

} else {

result = executeObservable(invokable, executionType, metaHolder);

}

} catch (HystrixBadRequestException e) {

throw e.getCause() != null ? e.getCause() : e;

} catch (HystrixRuntimeException e) {

throw hystrixRuntimeExceptionToThrowable(metaHolder, e);

}

return result;

}

复制代码

封装

image.png

image.png

image.png

默认为 SYNCHRONOUS

image.png

image.png

image.png

下面是Rxjava的相关编程,个人不是很熟

执行成功的逻辑

image.png

image.png

image.png

image.png

总结

在这里,由于面试中MySQL问的比较多,因此也就在此以MySQL为例为大家总结分享。但是你要学习的往往不止这一点,还有一些主流框架的使用,Spring源码的学习,Mybatis源码的学习等等都是需要掌握的,我也把这些知识点都整理起来了

面试真题

Spring源码笔记

加入社区:https://bbs.csdn.net/forums/4304bb5a486d4c3ab8389e65ecb71ac0
点都整理起来了

[外链图片转存中…(img-29m5yGNQ-1725633440206)]

[外链图片转存中…(img-Omu1Cs6e-1725633440206)]

加入社区:https://bbs.csdn.net/forums/4304bb5a486d4c3ab8389e65ecb71ac0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值