I use Spring Quartz scheduler(Clustered) in my application as follows. Inside the scheduler, i instantiate a thread class to spawn a new thread for each record and inside the thread class, i use reference of other bean class using wiring concept. As the thread class inside the scheduler is instantiated using the new operator, the dependency injection inside the thread class is not working. Is there any way, we can achieve this?
I may not be able to go with this as i use ThreadPoolExecutor and the excute method needs runnable implementor. Also, i can configure many things in ThreadPoolExecutor. Is there any other equivalent class in Spring?
The executor provided must of course must have a bean definition in your context. It can be any Executor of type java.util.concurrent.Executor or org.springframework.core.task.TaskExecutor. Since ThreadPoolExecutor meets this criteria there is no reason you could not use it. Be aware if there are multiple methods within the class needing the async behavior this annotation can be applied at the class level as well.