We are using AEM on-prem as a headless CMS, and our users want to be able to schedule the publish/unpublish of multiple content fragments (CFs) at once by uploading a CSV file containing the paths of the CFs, the action (publish/unpublish), and the activation datetimes. The functionality should work just like what we do using the "Manage publication" wizard, but should be able to affect more CFs at the same time. The CSV file may contain more than 100 lines.
We have implemented a ResourceChangeListener to process the CSV, but we are not sure how to schedule the publish/unpublish of the CFs programmatically. We tried to use Replicator, but it can only affect immediately and is not able to schedule.
We are looking for guidance on how to achieve this functionality using AEM's APIs or any other recommended approach. Any help or insights would be greatly appreciated. Thank you in advance!
Solved! Go to Solution.
Views
Replies
Total Likes
Thanks @wei_lyu for elaborating on the usecase.
I believe, for such kind of replication tasks, Sling Scheduled Jobs are ideal, as they guarantee execution at least once.
1. Resource Change Listener can be implemented to handle and parse CSV (as mentioned above)
2. For every row in csv, Sling Job or a Sling Schedule Job can be created as per the schedule, where in the Listener will delegate the work to an executor, that is consumed by a Job Consumer. This guarantees execution and would not block the listener as well.
Please see following links as help docs:
For Replication API: please see this:
https://aem.redquark.org/2018/10/day-19-replication-api-in-action.html
For Scheduling:
https://aem.redquark.org/2018/10/day-13-schedulers-in-aem.html
For Sling Schedule Jobs (recommended):
https://blog.developer.adobe.com/handling-sling-schedulers-in-aem-as-a-cloud-service-cb59d5e59e9
Could you elaborate on your usecase:
-When do you want to schedule replication, for eg- daily, weekly etc
-On which resource, you have implemented Resource Change Listener
For Replication API: please see this:
https://aem.redquark.org/2018/10/day-19-replication-api-in-action.html
For Scheduling:
https://aem.redquark.org/2018/10/day-13-schedulers-in-aem.html
For Sling Schedule Jobs (recommended):
https://blog.developer.adobe.com/handling-sling-schedulers-in-aem-as-a-cloud-service-cb59d5e59e9
@krati_garg , thank you for your response!
To answer your questions:
To provide more context, the CSV file will look like this:
path,action,activation_date
/content/dam/mysite/aaa,PUBLISH,2023-10-10T13:50:00+09:00
/content/dam/mysite/bbb,UNPUBLISH,2023-10-11T15:30:00+09:00
Thanks @wei_lyu for elaborating on the usecase.
I believe, for such kind of replication tasks, Sling Scheduled Jobs are ideal, as they guarantee execution at least once.
1. Resource Change Listener can be implemented to handle and parse CSV (as mentioned above)
2. For every row in csv, Sling Job or a Sling Schedule Job can be created as per the schedule, where in the Listener will delegate the work to an executor, that is consumed by a Job Consumer. This guarantees execution and would not block the listener as well.
Please see following links as help docs:
For Replication API: please see this:
https://aem.redquark.org/2018/10/day-19-replication-api-in-action.html
For Scheduling:
https://aem.redquark.org/2018/10/day-13-schedulers-in-aem.html
For Sling Schedule Jobs (recommended):
https://blog.developer.adobe.com/handling-sling-schedulers-in-aem-as-a-cloud-service-cb59d5e59e9
Hello @wei_lyu
There are few options that you could try.
1. Using the onTime/offTime feature: Useful to decide availability of the pages. Specifically, if a lot of pages are to be made available during peak traffic
The following link explains the difference between onTime and publish
https://www.linkedin.com/pulse/onoff-time-aem-pages-veena-vikraman/
2. Use the OOTB "Schedule Page/Asset Activation" workflow. So, you could trigger the workflow, with required params, which would publish content when time is reached. It is the "manage publication" way.
3. You create your own custom workflow, add the step for "Absolute Time advancer". Once reached, workflow moves to next step and publishes the content.
Views
Likes
Replies
Views
Likes
Replies