Expand my Community achievements bar.

Check for Objects Replication Queue. AEM6.5

Avatar

Level 2

Hi All,

 

I am new to replication topic. I need few guidance here, where i worte one pseudo code. I have to deactive the list of pages through replicator api in a workflow in AEM6.5, but only if the objects in replication queue will be less than 500, means we're restricting to avoid load on replication agent incase if we're having more than 500 pages in replication queue then our workflow will not trigger or execute and show error message to author
reading the replication objects from
/var/eventing/jobs/assigned/212-212-212-hashcode/com.day.cq.replication.job.publish1india
/var/eventing/jobs/assigned/212-212-212-hashcode/com.day.cq.replication.job.publish2china
/var/eventing/jobs/assigned/212-212-212-hashcode/com.day.cq.replication.job.publish1japan

 

@Override
public void execute (WorkItem workItem, WorkflowSession workflowSession, MetaDataMap metaDataMap) throws
        WorkflowException {
            String payload = workItem.getWorkflowData().getPayload().toString();
            if (rootPage != null && replicationQueueChechk()) {
                replicator.replicate(session, ReplicationActionType.DEACTIVATE, paths, replicationOptions);
                //code goes here...
            }
}
private boolean replicationQueueChechk () {
            //TODO check the number of active objects in replication queue, return true only if replication queue is less than 500, otherwise return false
}

 

How to restrict this and avoid triggring the workflow, or let me know if there is any optimize way to achieve this

Thanks

 

cc: @kautuk_sahni  @arunpatidar  @lukasz-m  @VeenaVikraman  @Jagadeesh_Prakash 

4 Replies

Avatar

Community Advisor

@Marcos_aem  Once check below link for custom implementation 

 

https://kiransg.com/tag/bulk-replication/

 

CQ5.3: REPLICATION AGENTS FAIL DUE TO MAXIMUM JOB QUEUE LIMIT

The cause of this issue is the org.apache.sling.event.impl.JobEventHandler has a default limit of 10 on the number of job queues that the system can create.

Resolution
Increase the maximum number of Job queues as needed (the number of queues should be higher than the number of configured replication agents + number of workflow models)

  1. Log into the Felix Console (http://host:port/system/console/configMgr). 
  2. Go to the Configuration tab in Felix console. 
  3. Select "Apache Sling Job Event Handler (org.apache.sling.event.impl.JobEventHandler)" from the drop-down list. 
  4. Change "Max Job Queues" value. 
  5. Click save.

For more information, see http://helpx.adobe.com/experience-manager/kb/CQ53UnableToCreateJobQueueDueToMaxQueues.html.

 

https://helpx.adobe.com/experience-manager/kb/experience-manager-replication-faqs.html

Avatar

Community Advisor

Hi @Marcos_aem 

Yes, there is an easy way for it.

 

  • Get the replication queue from the session object
  • Get the entries list from the replication queue.
  • Get the size of the entries, and then de-activate based on it.
private boolean replicationQueueChechk (Session session) {
ReplicationQueue replicationQueue = Replication.getQueue(resourceResolver.adaptTo(session.class));  List<ReplicationQueueEntry> queueEntries = replicationQueue.entries();
 if (queueEntries.size() < 500) { 
// If yes, then deactivate the pages
} else {
//some message
}
}

 

Avatar

Level 2

Thank you @Anmol_Bhardwaj ,

I am just wondering if this will work for our custom created replication agent?

like as I mentioned I need to monitor the queue before seding for activate/deactivate.

 

which let say I can check from CRX under nodes example:
/var/eventing/jobs/assigned/212-212-212-hashcode/com.day.cq.replication.job.publish1india
/var/eventing/jobs/assigned/212-212-212-hashcode/com.day.cq.replication.job.publish2china
/var/eventing/jobs/assigned/212-212-212-hashcode/com.day.cq.replication.job.publish1japan

 

so will the above api will take care of this or need to create a custom one?