Replication

Adobe Experience Manager as a Cloud Service uses the Sling Content Distribution capability to move the content to replicate to a pipeline service run on Adobe I/O that is outside of the AEM runtime.

NOTE

Read Distribution for more information.

Methods of Publishing Content

Quick Un/Publish - Planned Un/Publish

This allows you to publish the selected page(s) immediately, without the additional options possible through the Manage Publication approach.

For more information, see Manage Publication.

On and Off Times - Trigger Configuration

The additional possibilities of On Time and Off Time are available from the Basic tab of Page Properties.

To realize the automatic replication for this you need to enable Auto Replicate in the OSGi configuration On Off Trigger Configuration:

OSGi On Off Trigger Configuration

Manage Publication

Manage Publication offers more options than Quick Publish, allowing for the inclusion of child pages, customization of the references, and starting any applicable workflows as well as offering the option to publish at a later date.

Including a folder’s children for the “publish later” option will invoke the Publish Content Tree workflow, described in this article.

You can find more detailed information on Manage Publication on the Publishing Fundamentals documentation.

Tree Activation

NOTE

This approach should be considered deprecated and will be removed on or after September 30th, 2021 since it does not persist statuses and is less scalable than other approaches. Adobe’s recommendation is to use manage publication or workflow methods instead

To perform a tree activation:

  1. From the AEM Start Menu navigate to Tools > Deployment > Distribution
  2. Select the card publish
  3. Once in the publish Web console UI, select Distribute
    Distribute
  4. Select the path in the path browser, choose to add a node, tree or delete as required and select Submit

For best performance, follow these guidelines when using this feature:

  • It is recommended to replicate fewer than 100 paths at a time, with a 500 path hard limit.
  • The total size of the replicated content must be below 5 MB. This just includes the nodes and properties, but not any binaries, which include workflow packages and content packages.

Publish Content Tree Workflow

You can trigger a tree replication by choosing Tools - Workflow - Models and copying the Publish Content Tree out-of-the-box workflow model, as shown below:

Do not modify or invoke the original model. Instead, make sure to first copy the model and then modify or invoke that copy.

Like all workflows, it can also be invoked via API. For more information, see Interacting with Workflows Programatically.

Alternatively, you can also achieve this by creating a Workflow Model that uses the Publish Content Tree process step:

  1. From the AEM as a Cloud Service homepage, go to Tools - Workflow - Models

  2. In the Workflow Models page, press Create in the upper right corner of the screen

  3. Add a title and a name to your model. For more information, see Creating Workflow Models

  4. Select the newly created model from the list, and press Edit

  5. In the following window, drag and drop the Process Step to the current model flow:

    Process Step

  6. Click the Process step in the flow and select Configure by pressing the wrench icon

  7. Click on the Process tab and select Publish Content Tree from the drop down list

    Treeactivation

  8. Set any additional parameters in the Arguments field. Multiple comma separated arguments can be stringed together. For example:

    enableVersion=true,agentId=publish

    NOTE

    For the list of parameters, see the Parameters section below.

  9. Press Done to save the Workflow model.

Parameters

  • replicateAsParticipant (boolean value, default: false). If configured as true, the replication is using the userid of the principal which performed the participant step.
  • enableVersion (boolean value, default: true). This parameter determines if a new version is created upon replication.
  • agentId (string value, default means only agents for publish are used). It is recommended to be explicit about the agentId; for example, setting it the value: publish. Setting the agent to preview will publish to the preview service
  • filters (string value, default means all paths are activated). Available values are:
    • onlyActivated - only paths which are not marked as activated will be activated.
    • onlyModified - activate only paths which are already activated and have a modification date later than the activation date.
    • The above can be ORed with a pipe “|”. For example, onlyActivated|onlyModified.

Logging

When the tree activation workflow step starts, it will log its configuration parameters on the INFO loglevel. When paths are activated, an INFO statement is also logged.

A final INFO statement will then be logged after the workflow step has replicated all paths.

Additionally you can increase the loglevel of the loggers below com.day.cq.wcm.workflow.process.impl to DEBUG/TRACE to get even more log information.

In case of errors, the workflow step terminates with a WorkflowException, which wraps the underlying Exception.

Below you will find examples of logs that are generated during a sample publish content tree workflow:

21.04.2021 19:14:55.566 [cm-p123-e456-aem-author-797aaaf-wkkqt] *INFO* [JobHandler: /var/workflow/instances/server60/2021-04-20/brian-tree-replication-test-2_1:/content/wknd/us/en/adventures] com.day.cq.wcm.workflow.process.impl.treeactivation.TreeActivationWorkflowProcess TreeActivation options: replicateAsParticipant=false(userid=workflow-process-service), agentId=publish, chunkSize=100, filter=, enableVersion=false
21.04.2021 19:14:58.541 [cm-p123-e456-aem-author-797aaaf-wkkqt] *INFO* [JobHandler: /var/workflow/instances/server60/2021-04-20/brian-tree-replication-test-2_1:/content/wknd/us/en/adventures] com.day.cq.wcm.workflow.process.impl.ChunkedReplicator closing chunkedReplication-VolatileWorkItem_node1_var_workflow_instances_server60_2021-04-20_brian-tree-replication-test-2_1, 17 paths replicated in 2971 ms

Resume Support

The workflow processes content in chunks, each of which represents a subset of the full content to be published. If for any reason the workflow is stopped by the system, it will restart and process the chunk that was not yet processed. A log statement will state that content has been resumed from a specific path.

Replication API

You can publish content using the Replcation API featured in AEM as a Cloud Service.

For more information, see the API Documentation.

Basic Usage of the API

@Reference
Replicator replicator;
@Reference
ReplicationStatusProvider replicationStatusProvider;

....
Session session = ...
// Activate a single page to all agents, which are active by default
replicator.replicate(session,ReplicationActionType.ACTIVATE,"/content/we-retail/en");
// Activate multiple pages (but try to limit it to approx 100 at max)
replicator.replicate(session,ReplicationActionType.ACTIVATE, new String[]{"/content/we-retail/en","/content/we-retail/de"});

// ways to get the replication status
Resource enResource = resourceResolver.getResource("/content/we-retail/en");
Resource deResource = resourceResolver.getResource("/content/we-retail/de");
ReplicationStatus enStatus = enResource.adaptTo(ReplicationStatus.class);
// if you need to get the status for more more than 1 resource at once, this approach is more performant
Map<String,ReplicationStatus> allStatus = replicationStatusProvider.getBatchReplicationStatus(enResource,deResource);

Replication with Specific Agents

When replicating resources as in the example above, only the agents which are active by default will be used. In AEM as a Cloud Service, this will only be the agent called “publish”, which connects the author to the publish tier.

To support the preview functionality, a new agent called “preview” has been added, which is not active by default. This agent is used to connect the author to the preview tier. If you want to replicate only via the preview agent, you need to explicitly select this preview agent via an AgentFilter.

See the example below on how to do this:

private static final String PREVIEW_AGENT = "preview";

ReplicationStatus beforeStatus = enResource.adaptTo(ReplicationStatus.class); // beforeStatus.isActivated == false

ReplicationOptions options = new ReplicationOptions();
options.setFilter(new AgentFilter() {
  @Override
  public boolean isIncluded (Agent agent) {
    return agent.getId().equals(PREVIEW_AGENT);
  }
});
// will replicate only to preview
replicator.replicate(session,ReplicationActionType.ACTIVATE,"/content/we-retail/en", options);

ReplicationStatus afterStatus = enResource.adaptTo(ReplicationStatus.class); // afterStatus.isActivated == false
ReplicationStatus previewStatus = afterStatus.getStatusForAgent(PREVIEW_AGENT); // previewStatus.isActivated == true

In case you do not provide such a filter and only use the “publish” agent, the “preview” agent is not used and the replication action does not affect the preview tier.

The overall ReplicationStatus of a resource is only modified if the replication action includes at least one agent which is active by default. In the above example this is not the case, as the replication is just using the “preview” agent. Therefore, you need to use the new getStatusForAgent() method, which allows querying the status for a specific agent. This method also works for the “publish” agent. It returns a non-null value if there has been any replication action done using the provided agent.

Replication API path and size limits

It is recommended to replicate fewer than 100 paths, with 500 being the hard limit. Above the hard limit, a ReplicationException will be thrown. If your application logic does not require atomic replication, this limit can be overcome by setting the ReplicationOptions.setUseAtomicCalls to false, which will accept any number of paths, but internally create buckets to stay below this limit. The amount of content transmitted per replication call must not exceed 5 MB, which includes the nodes and properties, but not any binaries (workflow packages and content packages are considered binaries).

Troubleshooting

To troubleshoot replication, navigate to the Replication Queues in the AEM Author Service Web UI:

  1. From the AEM Start Menu navigate to Tools > Deployment > Distribution
  2. Select the card publish
    Status
  3. Check the queue status which should be green
  4. You can test the connection to the replication service
  5. Select the Logs tab which shows the history of content publications

Logs

If the content couldn’t be published, the whole publication is reverted from the AEM Publish Service.
In that case, the main, editable queue will show a red status and should be reviewed in order to identify which item(s) caused the cancelation of the publication. By clicking that queue, its pending items will show up, from which a single item or all items can be cleared if needed.

On this page