26.9. Using a Spring TaskExecutor for @Asynchronous
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}"/>