java - Spring @Scheduled annotation -
how can use @scheduled annotation of spring dynamically?
crontrigger(string expression, timezone timezone)
as have multiple timezones in database, how can pass them dynamically?
i tried in code:
timezone timezone = null; string timezone1 = null; public schedulerbean(string timezone2) { this.timezone1 = timezone2; //constructor } @scheduled(cron="0 0 8 * * ?", zone =timezone.gettimezone(timezone1) ) //error @ line public void sendquestionnotif() { //......code }
here error getting,
*type mismatch: cannot convert timezone string*
please me. because want trigger cron based on timezones. tia.
annotation parameters cannot set dynamically. can programmatically, this
class scheduler implements runnable { public scheduler(taskscheduler scheduler, string timezone, string cron) { scheduler.schedule(this, new crontrigger(cron, timezone.gettimezone(timezone))); } @override public void run() { // } }
Comments
Post a Comment