Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to run a task every minute

Avatar

Level 4

Hi,

I have in my local version of cq5 a thread that runs every minute, checks a queue and executes a task. It works fine.

I need now to export it in my production environment.

The production has a slave and a master therefore i need to execute my code only in the master.

@Properties({ @Property(name="scheduler.runOn", value="LEADER"), @Property(name="scheduler.expression", value="0 * * * * ?"), @Property(name="scheduler.concurrent",boolValue=false) })

My bundle is in production and with the system console i can see the process.

The first instruction of this process is a print to the error.log but if i inspect the log of the master and the slave i can't see nothing.

This is my logger:

protected final Logger log = LoggerFactory.getLogger(this.getClass());

Could it be that the log is redirected to another file?

I think that this process isn't started. How can i verify it?

Need i a procedure to refresh the quartz scheduler?

 

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

Please check at http://localhost:4502/system/console/status-slingscheduler whether you can see you scheduler details or not.

If not seing, please try to analyze logs when you are deploying code to prod.

How you are adding scheduler to any instance?

Please share code snippet, if this didnt helped

View solution in original post

6 Replies

Avatar

Level 10

There is a community article that shows how to do this. 

Scheduling Adobe Experience Manager Jobs using Apache Sling

It covers how to setup a SLign Expression to run a task:

 String schedulingExpression = "0 15 10 ? * MON-FRI"; //10:15am every Monday, Tuesday, Wednesday, Thursday and Friday

Hope this helps

Avatar

Correct answer by
Level 10

Hi,

Please check at http://localhost:4502/system/console/status-slingscheduler whether you can see you scheduler details or not.

If not seing, please try to analyze logs when you are deploying code to prod.

How you are adding scheduler to any instance?

Please share code snippet, if this didnt helped

Avatar

Level 4

I can't find the tab status-slingscheduler or something like that.

I can only see my process under tab http://localhost:4502/system/console/configMgr

Avatar

Level 10

There is no tab for this, see screenshot

please open : http://localhost:4502/system/console/status-slingscheduler url in your browser

Avatar

Employee Advisor

If you are on CQ 5.6.1 or later version then you can refer to the following code example- https://github.com/Adobe-Consulting-Services/acs-aem-samples/blob/master/bundle/src/main/java/com/ad...

And for versions < 5.6.1 , you need to implement the ClusterAware interface - https://helpx.adobe.com/experience-manager/kb/CreateClusterAwareOSGiService.html

Avatar

Level 4

I'm using CQ5.5.

I don't have the interface ClusterAware nor TopologyEventListener.