Search

26.9. Using a Spring TaskExecutor for @Asynchronous

download PDF
Spring provides an abstraction for executing code asynchronously, called a TaskExecutor. The Spring-Seam integration lets you use a Spring TaskExecutor to execute immediate @Asynchronous method calls. To enable this functionality, install the SpringTaskExecutorDispatchor and provide a Spring -bean defined taskExecutor like so:
<spring:task-executor-dispatcher  
        task-executor="#{springThreadPoolTaskExecutor}"/>
Because a Spring TaskExecutor does not support scheduling asynchronous events, you can provide handling with a fallback Seam Dispatcher, like so:
<!-- 
  Install a ThreadPoolDispatcher to handle scheduled asynchronous event
-->
<core:thread-pool-dispatcher name="threadPoolDispatcher"/>

<!-- Install the SpringDispatcher as default -->
<spring:task-executor-dispatcher 
        task-executor="#{springThreadPoolTaskExecutor}" 
        schedule-dispatcher="#{threadPoolDispatcher}"/>
Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat Documentation

We help Red Hat users innovate and achieve their goals with our products and services with content they can trust.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

© 2024 Red Hat, Inc.