Question

25.5.3 The Element

To enable both @Scheduled and @Async annotations, simply include the 'annotation-driven' element from the task namespace in your configuration.

<task:annotation-driven executor="myExecutor" scheduler="myScheduler"/>

<task:executor id="myExecutor" pool-size="5"/>

<task:scheduler id="myScheduler" pool-size="10"/>

Notice that an executor reference is provided for handling those tasks that correspond to methods with the @Async annotation, and the scheduler reference is provided for managing those methods annotated with @Scheduled.

Is there anyway to do this without XML?

Was it helpful?

Solution

This is possible with the newly-released Spring 3.1, but not 3.0 - See @EnableAsync and @EnableScheduling.

OTHER TIPS

For @Dejel question: (as I am not able to post comment)

It is possible to specify executor for certain task. This can be achieved by specyfing executor name as value of @Async annotation. See:

https://jira.spring.io/browse/SPR-6847

http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/scheduling/annotation/Async.html

http://www.baeldung.com/spring-async

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top