# Replication Api

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

- **Type:** Skill
- **Install:** `agentstack add skill-adobe-skills-replication-api`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [adobe](https://agentstack.voostack.com/s/adobe)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** Apache-2.0
- **Upstream author:** [adobe](https://github.com/adobe)
- **Source:** https://github.com/adobe/skills/tree/main/plugins/aem/6.5-lts/skills/aem-replication/replication-api
- **Website:** https://www.adobe.com/ai/overview.html

## Install

```sh
agentstack add skill-adobe-skills-replication-api
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# 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

    com.adobe.aem
    uber-jar
    apis
    provided

```

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 versions
    
    replicator.replicate(session, ReplicationActionType.ACTIVATE, pagePath, opts);
}
```

### Method 3: replicate(Session, ReplicationActionType, String[], ReplicationOptions)

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

**Parameters:**
- `session` - JCR session
- `type` - ReplicationActionType
- `paths` - Array of content paths (String[])
- `options` - ReplicationOptions

**Description:** Handles replication across multiple paths with supplied settings.

**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 activateMultiplePages(ResourceResolver resolver, String[] pagePaths) 
    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(false); // Async for better performance
    
    replicator.replicate(session, ReplicationActionType.ACTIVATE, pagePaths, opts);
}
```

### Method 4: checkPermission(Session, ReplicationActionType, String)

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

**Parameters:**
- `session` - JCR session
- `type` - ReplicationActionType
- `path` - Content path

**Throws:** `ReplicationException` if user lacks permissions

**Description:** Verifies whether a user has sufficient permissions for replication activities.

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

import javax.jcr.Session;

public boolean canUserActivate(ResourceResolver resolver, String pagePath) {
    Session session = resolver.adaptTo(Session.class);
    if (session == null) {
        throw new IllegalStateException("Unable to adapt ResourceResolver to Session");
    }
    try {
        replicator.checkPermission(session, ReplicationActionType.ACTIVATE, pagePath);
        return true; // User has permission
    } catch (ReplicationException e) {
        return false; // User lacks permission
    }
}
```

### Method 5: getReplicationStatus(Session, String)

**Signature:**
```java
ReplicationStatus getReplicationStatus(Session session, String path)
```

**Parameters:**
- `session` - JCR session
- `path` - Content path

**Returns:** `ReplicationStatus` object or `null` if unavailable

**Description:** Retrieves the replication status for a given path.

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

import javax.jcr.Session;
import java.util.Calendar;

public ReplicationInfo getPageReplicationInfo(ResourceResolver resolver, String pagePath) {
    Session session = resolver.adaptTo(Session.class);
    if (session == null) {
        throw new IllegalStateException("Unable to adapt ResourceResolver to Session");
    }
    ReplicationStatus status = replicator.getReplicationStatus(session, pagePath);
    
    if (status != null) {
        boolean isActivated = status.isActivated();
        Calendar lastPublished = status.getLastPublished();
        String lastPublishedBy = status.getLastPublishedBy();
        
        return new ReplicationInfo(isActivated, lastPublished, lastPublishedBy);
    }
    return null;
}
```

### Method 6: getActivatedPaths(Session, String)

**Signature:**
```java
Iterator getActivatedPaths(Session session, String path) 
throws ReplicationException
```

**Parameters:**
- `session` - JCR session
- `path` - Root path for subtree

**Returns:** Iterator of activated paths

**Throws:** `ReplicationException`

**Description:** Returns paths of all activated nodes for the given subtree path.

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

import javax.jcr.Session;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public List getActivatedPages(ResourceResolver resolver, String rootPath) 
    throws ReplicationException {
    Session session = resolver.adaptTo(Session.class);
    if (session == null) {
        throw new IllegalStateException("Unable to adapt ResourceResolver to Session");
    }
    Iterator activatedPaths = replicator.getActivatedPaths(session, rootPath);
    
    List result = new ArrayList<>();
    while (activatedPaths.hasNext()) {
        result.add(activatedPaths.next());
    }
    return result;
}
```

## ReplicationOptions Class

Encapsulates optional configuration parameters for replication requests.

**Official Documentation:** [ReplicationOptions JavaDoc](https://developer.adobe.com/experience-manager/reference-materials/6-5-lts/javadoc/com/day/cq/replication/ReplicationOptions.html)

### Key Methods:

#### setSynchronous(boolean)

**Description:** Controls whether replication executes synchronously (blocking) or asynchronously (default).

**Parameters:**
- `synchronous` - `true` for synchronous, `false` for asynchronous (default)

**Example:**
```java
ReplicationOptions opts = new ReplicationOptions();
opts.setSynchronous(true); // Wait for replication to complete
```

**Use cases:**
- Synchronous: When you need confirmation before proceeding (e.g., before redirecting user)
- Asynchronous: Better performance for bulk operations

**Thread-Blocking Implications:**

When `setSynchronous(true)` is used, the calling thread blocks until replication completes across all target agents. This has important implications:

- **UI Performance:** In servlets or sling models rendering pages, synchronous replication blocks the HTTP request thread. For large content or slow networks, this can cause noticeable page load delays or request timeouts.
- **Thread Pool Exhaustion:** High-traffic scenarios with synchronous replication can exhaust the servlet container's request thread pool, causing cascading failures.
- **Recommended Pattern:** Use asynchronous replication (`false`, the default) for user-facing operations. Reserve synchronous mode for background jobs, workflow steps, or cases where immediate confirmation is critical for correctness (e.g., transactional workflows).

**Performance Comparison:**
- Asynchronous: Request returns immediately after queueing (~10-50ms)
- Synchronous: Request waits for full replication cycle (500ms-5s typical, longer for large assets or network delays)

#### setFilter(AgentFilter)

**Description:** Sets the filter for selecting specific agents for replication.

**Parameters:**
- `filter` - `AgentFilter` implementation

**Example:**
```java
import com.day.cq.replication.AgentFilter;
import com.day.cq.replication.Agent;

ReplicationOptions opts = new ReplicationOptions();

// Filter to specific agent
opts.setFilter(new AgentFilter() {
    public boolean isIncluded(Agent agent) {
        return agent.getId().equals("publish_instance_1");
    }
});

replicator.replicate(session, ReplicationActionType.ACTIVATE, pagePath, opts);
```

**Use cases:**
- Target specific publish instance
- Exclude certain agents
- Route content to specific environments

#### setSuppressVersions(boolean)

**Description:** Controls whether to create versions during replication.

**Parameters:**
- `suppress` - `true` to skip version creation, `false` otherwise

**Example:**
```java
ReplicationOptions opts = new ReplicationOptions();
opts.setSuppressVersions(true); // Don't create versions (performance)
```

#### setSuppressStatusUpdate(boolean)

**Description:** Controls whether to update replication status.

**Parameters:**
- `suppress` - `true` to skip status update, `false`

…

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [adobe](https://github.com/adobe)
- **Source:** [adobe/skills](https://github.com/adobe/skills)
- **License:** Apache-2.0
- **Homepage:** https://www.adobe.com/ai/overview.html

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-adobe-skills-replication-api
- Seller: https://agentstack.voostack.com/s/adobe
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
