Claude
Skills
Sign in
Back

replication-api

Included with Lifetime
$97 forever

Use the AEM 6.5 LTS Replication API for programmatic content activation, deactivation, and replication status management

Backend & APIs

What this skill does


# AEM 6.5 LTS Replication API

This skill provides comprehensive guidance on using the official Adobe Experience Manager 6.5 LTS Replication API for programmatic replication operations. The API enables custom code to activate, deactivate, and manage content distribution workflows.

## When to Use This Skill

Use this skill when you need to:
- Programmatically activate/deactivate content from custom code
- Build custom replication workflows in OSGi services or servlets
- Integrate replication with external systems
- Implement custom replication triggers and automation
- Check replication status in application logic
- Create custom content distribution tools
- Bulk replicate content via scripts
- Implement conditional replication logic

## Prerequisites

- AEM 6.5 LTS environment with configured replication agents
- Java development environment for AEM
- Maven project with AEM dependencies
- Understanding of OSGi services and Sling ResourceResolver
- Configured replication agents (see `configure-replication-agent` skill)
- Service user or user session with replication permissions

## Official API Documentation

All public replication APIs are documented in the official Adobe AEM 6.5 LTS JavaDoc:

- **Package Summary (Complete API Reference)**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/package-summary.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/package-summary.html)
- **Replicator Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/Replicator.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/Replicator.html)
- **AgentManager Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/AgentManager.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/AgentManager.html)
- **ReplicationQueue Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationQueue.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationQueue.html)
- **ReplicationListener Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationListener.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationListener.html)
- **AgentFilter Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/AgentFilter.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/AgentFilter.html)
- **Agent Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/Agent.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/Agent.html)
- **ReplicationAction Class**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationAction.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationAction.html)
- **ReplicationOptions Class**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationOptions.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationOptions.html)
- **ReplicationStatus Interface**: [https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationStatus.html](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationStatus.html)

## Core API Components

### 1. Replicator Interface

The primary service for managing replication operations.

**Service Type:** OSGi Service  
**Package:** `com.day.cq.replication`  
**Interface:** `com.day.cq.replication.Replicator`

### 2. ReplicationActionType Enum

Defines the type of replication operation:

| Type | Purpose | Effect |
|------|---------|--------|
| `ACTIVATE` | Publish content | Sends to Publish instances |
| `DEACTIVATE` | Unpublish content | Removes from Publish |
| `DELETE` | Delete from Publish | Permanent removal |
| `TEST` | Test replication | Verifies connectivity |
| `REVERSE` | Reverse replicate | Publish → Author |
| `INTERNAL_POLL` | Internal polling | System use |

### 3. ReplicationOptions Class

Encapsulates optional parameters for replication requests.

### 4. ReplicationStatus Interface

Provides status information about replicated content.

## Maven Dependencies

The Replication API is provided by the AEM uber-jar. Add to your `pom.xml`:

```xml
<dependency>
    <groupId>com.adobe.aem</groupId>
    <artifactId>uber-jar</artifactId>
    <classifier>apis</classifier>
    <scope>provided</scope>
</dependency>
```

The uber-jar version should match your AEM 6.5 LTS installation. The Replication API (`com.day.cq.replication.*`) is included in the uber-jar and available at runtime.

## Replicator Interface Methods

### Method 1: replicate(Session, ReplicationActionType, String)

**Signature:**
```java
void replicate(Session session, 
               ReplicationActionType type, 
               String path) 
throws ReplicationException
```

**Parameters:**
- `session` - JCR session (user permissions determine access)
- `type` - ReplicationActionType (ACTIVATE, DEACTIVATE, DELETE, etc.)
- `path` - Content path to replicate (e.g., "/content/mysite/en/page")

**Throws:** `ReplicationException` if replication fails

**Description:** Triggers replication for a single path with default options.

**Example:**
```java
import com.day.cq.replication.Replicator;
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.replication.ReplicationException;
import org.apache.sling.api.resource.ResourceResolver;
import org.osgi.service.component.annotations.Reference;

import javax.jcr.Session;

@Reference
private Replicator replicator;

public void activatePage(ResourceResolver resolver, String pagePath) 
    throws ReplicationException {
    Session session = resolver.adaptTo(Session.class);
    if (session == null) {
        throw new IllegalStateException("Unable to adapt ResourceResolver to Session");
    }
    replicator.replicate(session, ReplicationActionType.ACTIVATE, pagePath);
}
```

### Method 2: replicate(Session, ReplicationActionType, String, ReplicationOptions)

**Signature:**
```java
void replicate(Session session, 
               ReplicationActionType type, 
               String path,
               ReplicationOptions options) 
throws ReplicationException
```

**Parameters:**
- `session` - JCR session
- `type` - ReplicationActionType
- `path` - Content path
- `options` - ReplicationOptions for custom configuration

**Description:** Initiates replication with customizable options for one path.

**Example:**
```java
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.replication.ReplicationException;
import com.day.cq.replication.ReplicationOptions;
import org.apache.sling.api.resource.ResourceResolver;

import javax.jcr.Session;

public void activatePageSync(ResourceResolver resolver, String pagePath) 
    throws ReplicationException {
    Session session = resolver.adaptTo(Session.class);
    if (session == null) {
        throw new IllegalStateException("Unable to adapt ResourceResolver to Session");
    }
    
    ReplicationOptions opts = new ReplicationOptions();
    opts.setSynchronous(true); // Wait for completion
    opts.setSuppressVersions(true); // Don't create v

Related in Backend & APIs