AEM Pages Faster

Consider a situation when you need to urgently replicate a website page, but the replication queue is full of other pages. It would be great if urgent items went to the top of the queue automatically, but AEM doesn’t provide high-priority replication out of the box. The good news is, you can tweak AEM settings manually to achieve this goal.

If there are multiple replication agents configured in the author instance and we replicate a bunch of pages, then all the publish instances will get the updates gradually in parallel. If we have a separate replication agent dedicated to high-priority tasks only, AEM will handle them together with the regular replication agent tasks.

For example, say there is a regular replication agent A that has items A1 through A1000 in the queue. There is also a separate agent for high-priority pages that has items H1 through H5. This means AEM will publish the pages in the following sequence: A1, H1, A2, H2, …, A5, H5, A6, A7, …, A1000.

This is a significant improvement compared to the default AEM agent, which would publish all of the A pages first.

So we need a separate replication agent that will only handle our high-priority replication tasks and will be excluded from normal replication. We will set up a workflow to send items into that agent. Then we can also make a scheduled service that will suspend all the ‘regular’ agents when there are items in the ‘high-priority’ queue.

1. Creating a separate replication agent to serve high-priority tasks

An out-of-the-box AEM instance has a default ‘publish’ replication agent.

Structure

Let’s copy it in CRXDE and rename the node to ‘publish_high’. Then we’ll edit its settings and enable the ‘ignore default’ checkbox on the ‘triggers’ tab.

Dialogbox

We’ve created a separate replication agent which is excluded from normal replication settings. Let’s configure a workflow to send replication jobs to that agent.

2. Configuring a high-priority replication workflow

The workflow model is simple — just one single process step backed by a java class.

Process

The code sends a payload page to the replicator service and specifies that our ‘publish_high’ agent should handle a replication job. Now we can run the workflow on a high-priority page that needs to be replicated.

Start Workflow

3. Suspending all regular agents if there are high-priority replication tasks in the backlog

The two steps we described above allow us to process high-priority replication jobs in parallel with the ‘regular’ replication jobs and thus speed up the publication process. But we can also postpone non-priority publication tasks altogether to replicate critical pages even faster.

For this, we need to implement a service that performs the following steps every 10 seconds:

  • makes sure high-priority agent queues are not empty, meaning something needs to be published with high priority
  • checks whether high-priority items and regular replication agents are active, then pauses regular agents
  • validates that no high-priority items and regular replication agents are still paused, then activates them

This service would stop any replication jobs other than the high-priority ones and resume the regular jobs again when high-priority jobs are done. The code snippet below is for illustrative purposes only. Do not use it in production as is.

These three steps are all you need to prioritize your replication queue.

Author: Denis Glushkov

How can we help you?
Contact Us

Recent Posts

Appery.io

New Website and Customizable Plans for Appery.io Appery.io, Exadel's low-code development platform launched a new website with added Plan Customization Options. The updates are designed to help low code developers get the most out of the development process.