0

IS it possible to return list of tasks (Runnable?) to spring, so spring execute them in serial order regardless exceptions thrown by each item?

I want spring to call 10 tasks in order: 1, 2, 3 and so on, and simply log exception if it occures

Looks like @Async may help, but how can I configure it from XML?

user996142
  • 2,753
  • 3
  • 29
  • 48

1 Answers1

0

If you want to execute the tasks serially it can done through a threadpool with just 1 thread in it:

ExecutorService executor = Executors.newSingleThreadExecutor();
executor.execute(yourrunnable);

You cannot configure @Async from xml, it has to be through annotations, also if you are considering @Async, you will need to provide an explicit executor as you want your tasks to be handled serially:

@Async("serialExecutor")
<task:executor id="serialExecutor" pool-size="1"/>
Biju Kunjummen
  • 49,138
  • 14
  • 112
  • 125