Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Programmatically activate pages in batches

Avatar

Level 4

I have to activate 1000 pages from  author to 7 publish servers daily .I want to schedule  this process.How do we programmatically activate these pages in batches ?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

You can create a scheduled cron job to activate the pages programmatically (see code sample for activation shared by @Kautuksahni). You can define the number of pages to activate in one run as configuration property of the job. 

Below are some of the example of cron jobs - 

https://github.com/sneakybeaky/AEM-Integration-Test-Example/blob/master/core/src/main/java/com/nined...

http://blogs.adobe.com/experiencedelivers/experience-management/scheduling_jobs_usingsling/

View solution in original post

7 Replies

Avatar

Administrator

Hi 

Option 1:- Using Curl

Activate

curl -u admin:admin -X POST -F path="/content/path/to/page" -F cmd="activate" http://localhost:4502/bin/replicate.json

Link:- https://gist.github.com/sergeimuller/2916697

 

Option 2:- Use Replicator OSGi service:

//

@Component public class MyComponent { @Reference private Replicator replicator; private void activatePage(Session session) { //... replicator.replicate(session, ReplicationActionType.ACTIVATE, pathToPage); //... } }

Link:- http://www.sotheanim.com/21-how-to-programmatically-activate-cq-page

 

I hope this would help you.

Thanks and Regards

Kautuk Sahni



Kautuk Sahni

Avatar

Level 9

@Sh1ju ,

The integration Spring batch framework with AEM is the right solution for dealing with batch processing. This isn't hard to integrate because AEM already has spring stuff.

Java Executer Framework for multithreading implementation also fits in your case.

 Here is the article to start with https://dzone.com/articles/spring-batch-hello-world-1

Jitendra

Avatar

Level 9

Let me know if you need more information about integrating Sprint batch with AEM.

Jitendra

Avatar

Level 4

Will this code activate these pages in 'batches' ?

Avatar

Correct answer by
Employee Advisor

You can create a scheduled cron job to activate the pages programmatically (see code sample for activation shared by @Kautuksahni). You can define the number of pages to activate in one run as configuration property of the job. 

Below are some of the example of cron jobs - 

https://github.com/sneakybeaky/AEM-Integration-Test-Example/blob/master/core/src/main/java/com/nined...

http://blogs.adobe.com/experiencedelivers/experience-management/scheduling_jobs_usingsling/

Avatar

Level 9

@Kunal23,

In my opinion, one cron job/Task would not be able to activate 1k pages. It would be too slow & time consuming process. Without batch process/ multithreading, we can't achieve ideal solution. 

Jitendra

Avatar

Employee Advisor

Well, page activation is not a resource intensive task as it just queues the pages for activation in replication agent queue. Also, the cron job is going to run in the background as a separate thread and in my opinion is a simple solution to achieve this.