Hi All,
We have a requirement to execute the sling servlet on the monthly basis. Actually I have added the content path of the sites in xml and updated this in content/dam, here I have used query builder for this and I wanted to execute this particular servlet on the monthly basis to generate the xml.
Please let me know if anyone has worked on the similar issue.
Thanks,
Views
Replies
Total Likes
You should explore the Sling scheduler service: https://sling.apache.org/documentation/bundles/scheduler-service-commons-scheduler.html
I think, you should move the servlet logic into the osgi service/component e.g. DoSomethingService and call that service in servlet e.g. ThisMyServlet and in your scheduler MyScheduler.
If you do not need servlet you can simply remove the servlet e.g. ThisMyServlet
Hi @arunpatidar ,
I have done the same way. I have created a service and called this service in servlet. Do I need to call this service in scheduler as well?
Thanks,
Hi @aaqibk92586681 ,
Whatever @arunpatidar suggested should help.
However, the use case you mentioned only needs a service (DoSomethingService) & a scheduler(MyScheduler that invokes DoSomething.doing()) which uses the service at given frequency according to CRON expression.
But, incase you also need an manual option to do the task, you can have a servlet at some path (/bin/execute/dosomething) and call it if required.
This approach will enable :
1. Scheduled job to do the task using scheduler at given frequency.
2. Option to also do the same job on demand by hitting the servlet endpoint.
And both would be using the same service custom code (here, DoSomething.doing())
Thanks,
Milind
Hi @milind_bachani ,
For now we are hitting below servlet manually to add the xml file in dam.
http://localhost:4502/bin/microsites/xmlgenarate?sitename=/content/we-retail/us/en/products
I created a service class to generated the searched path via query builder and I have called this particular service in servlet and I wanted to this servlet run on monthly basis that's why I wanted to add scheduler. Is there any way we can configure servlet path in scheduler config to execute this servlet and after running the scheduler the above process will generate automatically.
Thanks,
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies