Event handling in AEMaaCS / Run Java code after publish | Community
Skip to main content
Level 4
March 11, 2025
Solved

Event handling in AEMaaCS / Run Java code after publish

  • March 11, 2025
  • 1 reply
  • 815 views

What is the best way to tap into and run a bit of Java code whenever a publish occurs in AEMaaCS?

 

I have an API servlet that is fetching and returning some structured content from AEM. This servlet uses Caffeine to cache some computations in memory for an hour so that results don't get recomputed on every request. When a publish occurs in AEM, I want to run a function to clear this cache.

 

I tried the following but it doesn't appear to get triggered (at least locally). What's the best way to trigger a bit of Java code to run after a publish occurs?

 

@8220494(service = EventHandler.class, property = { EventConstants.EVENT_TOPIC + "=com/adobe/granite/content/replication/end" }) public class CustomPublishEvent implements EventHandler { @3214626 public ResourceResolverFactory rrFactory; @9944223 public void handleEvent(Event event) { // do something here... } }

 

1 reply

Tethich
Community Advisor
TethichCommunity AdvisorAccepted solution
Community Advisor
March 11, 2025
konstantyn_diachenko
Community Advisor
Community Advisor
March 11, 2025

Yes, I can confirm that solution in mentioned thread works fine for my client.

Kostiantyn Diachenko, Community Advisor, Certified Senior AEM Developer, creator of free AEM VLT Tool, maintainer of AEM Tools plugin.