This conversation has been locked due to inactivity. Please create a new post.
This conversation has been locked due to inactivity. Please create a new post.
How we can mention crone expression for shedulers in OSGI Configuration?
Solved! Go to Solution.
Views
Replies
Total Likes
You can use the code as below :
@AttributeDefinition( name = "Cron Expression", description = "Cron expression used by the scheduler", type = AttributeType.STRING) public String cronExpression() default "0 * * * * ?";
You can refer the following documents for more info on the same :
https://blog.developer.adobe.com/aem-6-4-creating-a-scheduler-using-osgi-r6-annotations-4ad0b8c6fce7
https://aem.redquark.org/2018/10/day-13-schedulers-in-aem.html
Thanks.
You can use the code as below :
@AttributeDefinition( name = "Cron Expression", description = "Cron expression used by the scheduler", type = AttributeType.STRING) public String cronExpression() default "0 * * * * ?";
You can refer the following documents for more info on the same :
https://blog.developer.adobe.com/aem-6-4-creating-a-scheduler-using-osgi-r6-annotations-4ad0b8c6fce7
https://aem.redquark.org/2018/10/day-13-schedulers-in-aem.html
Thanks.
Refer below code for cron expression at OSGI config.
@AttributeDefinition(
name = "scheduler.expression",
description = "Cron expression used by the scheduler",
type = AttributeType.STRING)
public String scheduler_expression() default "0 0 14 1/1 * ? *";
Scheduler will run daily at 2pm with this deafult expression. Next dates be like 12022-09-09 Fri 14:00:002.2022-09-10 Sat 14:00:003.2022-09-11
Refer https://blog.developer.adobe.com/aem-6-4-creating-a-scheduler-using-osgi-r6-annotations-4ad0b8c6fce7
You can declare it in the properties.
package sling.docu.examples;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.felix.scr.annotations.Property;
@Component
@Service(value = Runnable.class)
@Property( name = "scheduler.expression", value = "0 * * * * ?")
public class ScheduledCronJob implements Runnable {
/** Default log. */
protected final Logger log = LoggerFactory.getLogger(this.getClass());
public void run() {
log.info("Executing a cron job (job#1) through the whiteboard pattern");
}
//
}
Checkout the documentation: Apache Sling :: Scheduler Service (commons scheduler)
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies