05 2021 档案
摘要:基于Redisson的分布式锁。 从多个节点获取锁,当一半以上的节点成功获取锁,才算成功获取锁。 redisson不会产生死锁问题,原因: redisson 有个开门狗机制,每隔10s会设置锁的有效期为30s 使用apollo的addChangeListener方法监听配置。 Redis Pttl
阅读全文
摘要:1、CAS 多个线程同CAS更新同一个变量,只有一个线程能成功,其他的都失败,但不会挂起,只是通知其他线程再次尝试。 包含三个值:内存值V,进行比较的预期原值A、准备写入的新值B。如果V和A相等,则将V更新为B。 2、AQS(AbstractQueuedSynchronizer) 内部通过Node构
阅读全文
摘要:使用场景: 1、异步处理,比如订单完成后想异步发送消息 2、事件告知,比如想知道spring容器是否启动完成,那么就可以监听spring启动完成后的事件 3、扩展处理,比如监听 跑完步 这个事件,接着会喝水。考虑到后面可能跑完步还要去吃饭,那么可以通过监听同一个事件来完成。 省的还需要改原来的代码。
阅读全文
摘要:1 finishBeanFactoryInitialization->preInstantiateSingletons 2 3 在preInstantiateSingletons的getBean()的方法中会实例化带有@RequestMapping、@Controller、@RestControll
阅读全文
摘要:main:11, ServerApplicationrun:1230, SpringApplicationrun:1242, SpringApplicationrun:297, SpringApplicationprepareEnvironment:338, SpringApplicationenv
阅读全文
摘要:1 @Override 2 public void afterPropertiesSet() throws Exception { 3 final RocketMQMessageListener annotation = MyConsumer.class.getAnnotation(RocketMQ
阅读全文
摘要:多个服务器的情况下: 相同 topic 、consumerGroup tag 默认 均衡消费消息 相同 topic 、consumerGroup 当存在不同Tag的时候,会导致消费混乱,比如TagA的消息被TagB的消费者消费了。 相同topic 不同consumerGroup 默认tag,每个服务
阅读全文
摘要:https://www.cnblogs.com/liuyk-code/p/9886033.html 里面用的spring版本是4.xx @Around("pointcut()")public Object doAround(ProceedingJoinPoint pjp) throws Throwa
阅读全文
摘要:1 // Process any @ComponentScan annotations 2 Set<AnnotationAttributes> componentScans = AnnotationConfigUtils.attributesForRepeatable( 3 sourceClass.
阅读全文
摘要:1 protected final SourceClass doProcessConfigurationClass( 2 ConfigurationClass configClass, SourceClass sourceClass, Predicate<String> filter) 3 thro
阅读全文