I'm using the Spring task executor system for the first time and just cannot get it to work...
I've read the various posts on SO already about this but can get no indication that the task is being executed. First of all I tried @Scheduled annotations on my service beans but after reading that this encountered problems with AOP proxies I'm using straight XML configuration as so:
<task:executor id="executorWithPoolSizeRange"
pool-size="5-25"
queue-capacity="100" />
<task:scheduler id="taskScheduler" pool-size="2" />
<task:scheduled-tasks>
<task:scheduled ref="fileWriter" method="test" fixed-rate="5000" />
</task:scheduled-tasks>
With fileWriter bean being a regular Spring bean with the test method as so:
public void test (){
System.err.println("run in job");
}
From running with DEBUG logging settings I know the following:
- The beans are loaded and initialised.
- If I mistype the name of the 'method' attribute, an exception is thrown, so the task definition is at least parsed.
- There is nothing in the debug statements indicating any activation of the task
- A breakpoint in the test method is never triggered.
I'm expecting to see that every 5 seconds while either my app or spring unit tests are running, to see the message from the test() method printed out on the console. I'm using Spring 3.0.6 and testing the app running through Jetty in Eclipse 3.7 on Mac 10.6 Java 6. All other Spring features we use (database, security, MVC work fine). Would be really grateful for any suggestions!