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.
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 @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())
Hi @milind_bachani ,
For now we are hitting below servlet manually to add the xml file in dam.
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.