Expand my Community achievements bar.

SOLVED

Scheduler is not updating the component attributes on the live page

Avatar

Level 2

Hello there!   

Objective: my scheduler is supposed to update my component properties "nome" and "idade" (name and age) to blank/null values every 30 seconds (or any short period of time). I tried to change my code so many times, but I'm lost as I don't get what's the problem here.   

For example: now the properties "nome" and "idade" have no values. Then I go to Postman and set the "nome" as "John" and the "idade" as "25". It correctly reflects on the AEM page. However, the scheduler is not clearing those values. I want them to go back go blank/null values every 30 seconds, but I couldn't get it to work. I also tried making the scheduler set fixed values, such as "Bob" and "20", but it didn't reflect on the AEM page as well.   

Could you help me with guidance?    

I'm attaching here my model code (ModelTeste.java):   
https://pastecode.io/s/ygqg4cfp  

It has the properties "nome" and "idade".   

Here is my servlet code (TesteServlet.java). I got it to work, and its objetive is being able to update the values of "nome" and "idade" via an external request (in my case, Postman):    

https://pastecode.io/s/psutgjdf  

Here is my scheduler code (CleanupScheduler.java):  
https://pastecode.io/s/2pnu0o86  

I tried with different times (30 seconds, 1 minute, 5 minutes) and it never worked, I think the logic itself might be wrong, but I checked basically all available guides and videos about schedulers and I need further guidance on what's wrong/needs to be changed.   

And here is my "modelteste.html" code if you need it:   
https://pastecode.io/s/b15sc0x4  

Thank you for your attention in advance! 





1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @edo_wjp 
Is your scheduler is running? If not then check the cron expression e.g. https://github.com/arunpatidar02/aem63app-repo/blob/master/java/SimpleScheduledTask.java

If scheduler is running, then you have issues with the session,

try (ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(null))

 

you need a valid resourceResolver using subservice

https://medium.com/@manumathew28.94/aem-system-users-1b9ab48df19e 



Arun Patidar

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @edo_wjp 
Is your scheduler is running? If not then check the cron expression e.g. https://github.com/arunpatidar02/aem63app-repo/blob/master/java/SimpleScheduledTask.java

If scheduler is running, then you have issues with the session,

try (ResourceResolver resourceResolver = resolverFactory.getServiceResourceResolver(null))

 

you need a valid resourceResolver using subservice

https://medium.com/@manumathew28.94/aem-system-users-1b9ab48df19e 



Arun Patidar