Programmatically activate pages in batches | Community
Skip to main content
Sh1ju
January 11, 2016
Solved

Programmatically activate pages in batches

  • January 11, 2016
  • 7 replies
  • 3946 views

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 ?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Kunal_Gaba_

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/ninedemons/aemtesting/core/impl/schedulers/SimpleScheduledTask.java

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

7 replies

kautuk_sahni
Community Manager
Community Manager
January 11, 2016

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
Jitendra_S_Toma
January 11, 2016

@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

Jitendra_S_Toma
January 11, 2016

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

Jitendra

Sh1ju
Sh1juAuthor
January 11, 2016

Will this code activate these pages in 'batches' ?

Kunal_Gaba_
Kunal_Gaba_Accepted solution
January 11, 2016

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/ninedemons/aemtesting/core/impl/schedulers/SimpleScheduledTask.java

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

Jitendra_S_Toma
January 11, 2016

@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

Kunal_Gaba_
January 11, 2016

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.