Sometimes we need to execute the job from controller, for example, you have to execute job and there in the job you have to do something with the requested params, So here in this case grails Quartz plugins provides the way to execute job from your controller so that you can provide the requested parameter to the job.
Look at the code written below to do so.
Quartz job in grails:
package com.retailerdev class NameOfYourJob { static triggers = { // leave this block empty } def execute(context) { def id = context.mergedJobDataMap.get(‘id’) } }
Controller Calling The Job:
package com.retailerdev class NameOfYourController { def quartzScheduler def someAction() { def id = params.id NameOfYourJob .triggerNow([id:id]) } }
To call the job from your controller you need to inject quartzScheduler then call the triggerNow function with reference of your job class like written above in the controller.
Note: Ensure that the package structure of your job class must be same as your controller class in order to call the job from controller.
Thanks
summy saurav
More From Oodles
Ready to innovate? Let's get in touch
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Summy Saurav
Summy is a kind of conscientious type of personality always be stable and practical in making decision; quick learner and problem solving attitude within a team . He is Fond of drawing,reading and computer programming