I can run a cron from a static trigger from within the job folder and it will execute, but when I try to fire a trigger from my controller it just plain fails...What am I missing?
ERROR CODE: No signature of method: static com.example.TaskReminderJob.triggerNow() is applicable for argument types: (java.util.LinkedHashMap) values: [[params:[name:Frank, email:[email protected]]]]
Quartz Job 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 THE JOB
package example
class UserController {
def quartzScheduler
...
//user is created
...
TaskReminderJob.triggerNow([name:"frank",email:"[email protected]"] )
}
Correct your package path and then you can trigger your job manually using triggerNow
method. And if you need to pass any parameter to it you can pass it like this:
Controller
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')
...
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With