@Override protected void applyReceiveOnlyAdviceChain(Collection<Advice> chain) { if (!CollectionUtils.isEmpty(chain)) { if (AopUtils.isAopProxy(this.source)) { Advised advised = (Advised) this.source; this.appliedAdvices.forEach(advised::removeAdvice); chain.stream().forEach(advice -> advised.addAdvisor(adviceToReceiveAdvisor(advice))); } else { ProxyFactory proxyFactory = new ProxyFactory(this.source); chain.stream().forEach(advice -> proxyFactory.addAdvisor(adviceToReceiveAdvisor(advice))); this.source = (MessageSource<?>) proxyFactory.getProxy(getBeanClassLoader()); } this.appliedAdvices.clear(); this.appliedAdvices.addAll(chain); if (!(isSyncExecutor()) && logger.isWarnEnabled()) { logger.warn(getComponentName() + ": A task executor is supplied and " + chain.size() + "MessageSourceMutator(s) is/are provided. If an advice mutates the source, such " + "mutations are not thread safe and could cause unexpected results, especially with " + "high frequency pollers. Consider using a downstream ExecutorChannel instead of " + "adding an executor to the poller"); } } }
@Override protected void applyReceiveOnlyAdviceChain(Collection<Advice> chain) { if (!CollectionUtils.isEmpty(chain)) { if (AopUtils.isAopProxy(this.source)) { Advised advised = (Advised) this.source; this.appliedAdvices.forEach(advised::removeAdvice); chain.stream().forEach(advice -> advised.addAdvisor(adviceToReceiveAdvisor(advice))); } else { ProxyFactory proxyFactory = new ProxyFactory(this.source); chain.stream().forEach(advice -> proxyFactory.addAdvisor(adviceToReceiveAdvisor(advice))); this.source = (MessageSource<?>) proxyFactory.getProxy(getBeanClassLoader()); } this.appliedAdvices.clear(); this.appliedAdvices.addAll(chain); if (!(isSyncExecutor()) && logger.isWarnEnabled()) { logger.warn(getComponentName() + ": A task executor is supplied and " + chain.size() + "MessageSourceMutator(s) is/are provided. If an advice mutates the source, such " + "mutations are not thread safe and could cause unexpected results, especially with " + "high frequency pollers. Consider using a downstream ExecutorChannel instead of " + "adding an executor to the poller"); } } }