Quartz job execution with a trigger from the controller

I can start cron from a static trigger from the tasks folder, and it will execute, but when I try to start a trigger from my controller, it just fails ... What am I missing?

ERROR CODE: No method signature: static com.example.TaskReminderJob.triggerNow () is applicable for argument types: (java.util.LinkedHashMap) values: [[params: [name: Frank, email: frank @ test.com]]]

Quartz work in grails-app / jobs / example

package com.example class TaskReminderJob { def reminderMailService static triggers = { } def execute(context) { def email = context.mergedJobDataMap.get('email') def name = context.mergedJobDataMap.get('name') reminderMailService.remindMail1(name, email) //send email via service } } 

CONTROLLER CALLING FOR WORK

 package example class UserController { def quartzScheduler ... //user is created ... TaskReminderJob.triggerNow([name:"frank",email:" frank@test.com "] ) } 
+4
source share
1 answer

Correct the package path, and then you can start your task manually using the triggerNow method. And if you need to pass any parameter, you can pass it as follows:

 package com.example class UserController { def someAction(){ ... TaskReminderJob.triggerNow([id:params.id]) } 

Job

 package com.example class TaskReminderJob { static triggers = {} def execute(context) { def id = context.mergedJobDataMap.get('id') ... } } 
+11
source

Source: https://habr.com/ru/post/1500840/


All Articles