36 articles and counting
      

Scheduling a Method Invocation with Spring and Quartz

I was wanting to run a scheduled task recently using Spring and Quartz. Here is a little snippet you may find useful if you are simply wanting to invoke a method:

< ?xml version="1.0" encoding="UTF-8"?>


	

			


			
		
	

	



	

	
	


There are various triggers you can use – Im using a cron trigger in this example. The cron pattern example triggers this job every 2 minutes - value=”0 0/2 * * * ?”.  You need to specify the jobDetail property with a reference to your job bean – in this case the MethodInvokingJobDetailFactoryBean. The targetObject and targetMethod reference your implementation where you wish to do some work – this this case com.myapp.scheduledtask.FeedRefreshScheduledTask.execute() is where we are doing some work.