event-migration

Migrate OSGi EventHandler and JCR EventListener code to AEM Cloud Service patterns.

1|Updated Jun 22, 2026
One-click install
npx skills add https://github.com/aemgdc/aemdev --skill event-migration-aemgdc
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: event-migration
Source: https://github.com/aemgdc/aemdev/tree/main/.agents/skills/event-migration
Command: npx skills add https://github.com/aemgdc/aemdev --skill event-migration-aemgdc

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Legacy AEM event handlers that run business logic inline on the shared OSGi event thread, use removed administrative resolvers, or fire on every cluster pod break or degrade performance on AEM as a Cloud Service. This Skill guides the migration of those handlers to the supported lightweight EventHandler plus JobConsumer split. ## Core Features & Use Cases - Handler Migration: Converts javax.jcr.observation.EventListener and inline-logic OSGi EventHandler classes into a lightweight EventHandler that offloads work via JobManager.addJob to a JobConsumer. - Routing & Classification: Routes resource-change observation to ResourceChangeListener and external notifications to AEM Eventing, so each concern lands on the correct Cloud Service API. - Cluster-Safe Execution: Adds TopologyEventListener leader election, service-user resolver setup with Repoinit and ServiceUserMapperImpl amended mappings, plus review checklists and troubleshooting guidance. - Use Case: A legacy replication EventHandler writes cq:lastReplicated inline using an administrative resolver. This Skill rewrites it as a leader-gated handler that enqueues a Sling Job, with a JobConsumer using a mapped service user and proper JobResult classification. ## Quick Start Migrate my legacy replication EventHandler class to the AEM Cloud Service lightweight handler and JobConsumer pattern.

Frequently Asked Questions about event-migration

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I migrate an OSGi EventHandler to AEM as a Cloud Service?▼

Make handleEvent lightweight by extracting only event data and calling jobManager.addJob, then move all business logic into a new JobConsumer class. The consumer uses getServiceResourceResolver with a mapped subservice instead of the removed administrative resolver.

How to replace javax.jcr.observation.EventListener in AEM Cloud Service?▼

Most JCR observation listeners should become ResourceChangeListener implementations, which is the supported API on Cloud Service. Only rare non-resource cases convert to an OSGi EventHandler subscribed to a documented non-resource topic.

Why does my event handler run multiple times on AEM author?▼

OSGi events can be delivered to every author cluster pod, so side-effecting handlers execute once per pod. Implement TopologyEventListener and gate handleEvent on the isLeader flag to elect a single executing instance.

Can I use getAdministrativeResourceResolver on AEM as a Cloud Service?▼

No, getAdministrativeResourceResolver is removed from the Cloud Service SDK. Use getServiceResourceResolver with a subservice name, backed by a Repoinit-created service user and a ServiceUserMapperImpl amended principal-name mapping.

When should I use ResourceChangeListener instead of EventHandler?▼

Use ResourceChangeListener whenever you observe repository content changes such as pages, assets, or properties being added, changed, or removed. EventHandler is only for non-resource OSGi Event Admin topics like replication and workflow events.