我有以下的石英工作在我的應用程序運行的觸發:石英工作從Config.groovy中
class ScraperJob {
def scraperService
static triggers = {
cron name: 'scraperTrigger', cronExpression: "0 0 * * * ?" // run every minute
}
def execute(){
try {
scraperService.storing()
log.info "${new Date()} - Scraping went smoothly."
}
catch(IOException) { // Connexion problem
log.error "${new Date()} - Method: parsing >> Connexion down or interrupted while parsing !"
}
catch(SAXException) { // Any SAXParser exception
log.error "${new Date()} - Method: parsing >> Parser error."
}
finally { // if not closed, the application crashes when the connexion fails
scraperService.slurper.finalize()
scraperService.parser.finalize()
}
}
}
我想知道是否有可能從Config.groovy
文件中設置的triggers
屬性。如果是這樣,你能解釋一下嗎?
啊啊,我很感動!就是這樣。比你非常多 –
;) - 沒問題!這是關閉的,所以我很高興它的工作。 –
哦,實際上我認爲它是有效的,因爲我的工作正好是在我告訴他時觸發的,但那是因爲它一直在後臺運行。 我還沒有管理尚未從BootStrap啓動它,但我在它:) –