Scheduler is nothing but just another OSGi service. You can look at it just like a servlet in this case, when we push code changes and then deploy, even if the server restarts, the servlets start running as soon as the bundle is active.
/** * This method will return the name of the Scheduler * * @2007960 {@link String} */ @AttributeDefinition(name = "Scheduler name", description = "Name of the scheduler", type = AttributeType.STRING) public String schdulerName() default "Task Notification scheduler configuration";
/** * This method will set flag to enable the scheduler * * @2007960 {@link Boolean} */
@AttributeDefinition(name = "Enabled", description = "True, if scheduler service is enabled", type = AttributeType.BOOLEAN) public boolean enabled() default false;
/** * This method returns the Cron expression which will decide how the scheduler * will run * * @2007960 {@link String} */
@AttributeDefinition(name = "Cron Expression", description = "Cron expression used by the scheduler", type = AttributeType.STRING) public String cronExpression() default "0 * * * * ?";
/** * This method returns the Asset Path * * * @2007960 {@link String} */
@AttributeDefinition(name = "Asset Path", description = "Asset Path", type = AttributeType.STRING) public String assetPath() default "/content/dam";
/** * @380 debal * * A cron-job like tasks that get executed regularly. */ @8220494(service = Runnable.class, immediate = true) @Designate(ocd = TaskNotificationSchedulerConfiguration.class) public class TaskNotificationScheduler implements Runnable {
private final Logger logger = LoggerFactory.getLogger(TaskNotificationScheduler.class);
this.contentDampath = configguration.assetPath(); this.schedulerName = configguration.schdulerName(); logger.info("**** Task Notification Scheduler ****"); //This scheduler will continue to run automatically even after the server reboot, otherwise the scheduled tasks will stop running after the server reboot. addScheduler(configguration); }
@9182423 protected void modified(TaskNotificationSchedulerConfiguration configguration) { // Remove the scheduler registered with old configuration removeScheduler(configguration);
contentDampath = configguration.assetPath(); // Add the scheduler registered with new configuration addScheduler(configguration);
hi @shikhasoni1 , can you elaborate your question? Do you mean if the server restarts/redeployment happens while the scheduler job in progress, will it keep doing the job?
Scheduler is nothing but just another OSGi service. You can look at it just like a servlet in this case, when we push code changes and then deploy, even if the server restarts, the servlets start running as soon as the bundle is active.