Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Set up PageEvent Handler/Listener


Level 1

Hello AEM Community

Im currently working on setting up a event handler for page creations and deletions on aem to then call one of our vendors API.

Ive been basing my work on a module we already have that listens to replication events.

So far i was able to reproduce that behavior on my module and trigger the code upon replications. However, i only need the calls to the API on Page Publications and deletions.

Ive been trying to find how to diferentiate between replications and page deletions and activations.

So far, it seems that AEM handles crx replications and page publications as the same type of event "type= ACTIVATION".

If i delete a page, it does set the type as "DELETE" so i can work with that to call  the API but for the page publications im lost since as i mentioned, AEM looks like it handles CRX replications and pages publications as the same type.

After some research, i found the PageEvent API and I tried to set up a Page Event Listener but it is not getting triggered upon publications or deletions of pages, so im not sure that if what im trying to do its possible or maybe my componet is located on a wrong part of the project to listen for Page Events.

Thanks beforehand

9 Replies


Employee Advisor

What is the difference between "CRX replication" and "page publication" from your point of view?


Level 1


So, for example, if i go to crx and i replicate any of the files we already have being html, css or js, i get a replicate type=ACTIVATE event.

However, we only want to catch whenever a new page is created or deleted.

Not sure if that answers your question


Level 10

Have you written code that uses the PageEvent API:"The Adobe AEM Quickstart and Web Application."

This is certainly the API to use to capture page changes.

Can you post it so the community can see if its properly set up to help solve your issue?


Level 1

yes, ill post what i have currently.

I dont see an option to edit the original post so ill post it here.


   configurationPolicy = ConfigurationPolicy.REQUIRE,
   immediate = true,
   service = EventHandler.class)

@Designate(ocd = APIConfiguration.class)

public class CustomEventListener implements EventHandler {

   private static final Logger LOGGER = LoggerFactory.getLogger(CustomEventListener.class);

  public void handleEvent(final Event event) {

   LOGGER.debug("handling event");
   PageEvent pgEvent = PageEvent.fromEvent(event);



on my config class i have:


   name = "API Connection Details",
   description = "APIConnection Details")

public @interface APIConfiguration {


   name = EventConstants.EVENT_TOPIC,
   description = "Page Action Event"

  String page_topics() default PageEvent.EVENT_TOPIC;

So whenever i either create a new page or delete it from AEM Dashboard the code doesnt get triggered.

It only works if add the replication topic to the config class.


Employee Advisor

When you want to track creation or deletion of pages (and ignore all activation and deactivation stuff) on a single instance, you can use eventing for it.

Create a page in your AEM instance then check localhost:4502/system/console/events for the event describing the page creation.


Level 1

ok, seems that the topic would be: org/apache/sling/api/resource/Resource/ADDED for page additions

And org/apache/sling/api/resource/Resource/REMOVED


Level 1

I set both topics on the configuration file

topics config.png

but i still dont get the event triggered upon page addition or deletion even tho i can see the event with the topic being generated correctly on /system/console/events


Level 1

any idea why it wont tigger even if the topics are bindend to the module?


Community Advisor

Debug the code to check if it get's registered and listens to the topics or not? If not, then possibly you're running into some API versions/library versions conflicts.

check if this helps - java - AEM 6.3 - Creating Event handler using OSGi R6 annotations - Stack Overflow

this one uses SCR annotations - Adobe CQ Help | Creating Replication Event Handlers for Adobe Experience Manager