How to run a task every minute | Adobe Higher Education
Skip to main content
Level 4
October 16, 2015
Risolto

How to run a task every minute

  • October 16, 2015
  • 6 risposte
  • 2141 visualizzazioni

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

Questo argomento è stato chiuso alle risposte.
Migliore risposta di edubey

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

6 risposte

smacdonald2008
Level 10
October 16, 2015

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

edubey
edubeyRisposta
Level 10
October 16, 2015

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

Level 4
October 16, 2015

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

edubey
Level 10
October 16, 2015

There is no tab for this, see screenshot

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

Kunal_Gaba_
October 16, 2015

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/adobe/acs/samples/schedulers/impl/ClusterAwareScheduler.java 

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

Level 4
October 16, 2015

I'm using CQ5.5.

I don't have the interface ClusterAware nor TopologyEventListener.