Aysnc的非同步執行的線程池

來源:互聯網
上載者:User

標籤:data   rop   return   config   pre   ack   may   exec   sync   

ProxyAsyncConfiguration.java源碼:

@Configuration@Role(BeanDefinition.ROLE_INFRASTRUCTURE)public class ProxyAsyncConfiguration extends AbstractAsyncConfiguration {    @Bean(name = TaskManagementConfigUtils.ASYNC_ANNOTATION_PROCESSOR_BEAN_NAME)    @Role(BeanDefinition.ROLE_INFRASTRUCTURE)    public AsyncAnnotationBeanPostProcessor asyncAdvisor() {        Assert.notNull(this.enableAsync, "@EnableAsync annotation metadata was not injected");        AsyncAnnotationBeanPostProcessor bpp = new AsyncAnnotationBeanPostProcessor();        Class<? extends Annotation> customAsyncAnnotation = this.enableAsync.getClass("annotation");        if (customAsyncAnnotation != AnnotationUtils.getDefaultValue(EnableAsync.class, "annotation")) {            bpp.setAsyncAnnotationType(customAsyncAnnotation);        }        if (this.executor != null) {            bpp.setExecutor(this.executor);        }        if (this.exceptionHandler != null) {            bpp.setExceptionHandler(this.exceptionHandler);        }        bpp.setProxyTargetClass(this.enableAsync.getBoolean("proxyTargetClass"));        bpp.setOrder(this.enableAsync.<Integer>getNumber("order"));        return bpp;    }}

 

AbstractAsyncConfiguration.java源碼:

    @Autowired(required = false)    void setConfigurers(Collection<AsyncConfigurer> configurers) {        if (CollectionUtils.isEmpty(configurers)) {            return;        }        if (configurers.size() > 1) {            throw new IllegalStateException("Only one AsyncConfigurer may exist");        }        AsyncConfigurer configurer = configurers.iterator().next();        this.executor = configurer.getAsyncExecutor();        this.exceptionHandler = configurer.getAsyncUncaughtExceptionHandler();    }

 

看AsyncDefaultAutoConfiguration.java源碼:

public class AsyncDefaultAutoConfiguration {    @Autowired private BeanFactory beanFactory;    @Configuration    @ConditionalOnMissingBean(AsyncConfigurer.class)    @ConditionalOnProperty(value = "spring.sleuth.async.configurer.enabled", matchIfMissing = true)    static class DefaultAsyncConfigurerSupport extends AsyncConfigurerSupport {        @Autowired private BeanFactory beanFactory;        @Override        public Executor getAsyncExecutor() {            return new LazyTraceExecutor(this.beanFactory, new SimpleAsyncTaskExecutor());        }    }

 更多的SimpleAsyncTaskExecutor見《spring線程池(同步、非同步)》

Aysnc的非同步執行的線程池

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.