Event handler for replication complete in AEM | Community
Skip to main content
August 13, 2019
Solved

Event handler for replication complete in AEM

  • August 13, 2019
  • 3 replies
  • 4053 views

I have a requirement where i need to trigger a mail when page is delivered to publishing target with the page links and some title and description in the mail body.

What is the best approach to proceed in this scenario. I have tried using Replication Handler but that doesn't give me event when the page is delivered to target it raises the event only when it is activated not delivered.

Pleas help me to find best approach to this problem.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Amit-Tiwari

I think you should write a workflow-

1.It should be triggered on modified event under /content/yourproject

2.it should be triggered on publish environment only

and from the workflow payload you will get the page details that you can use to send a mail from workflow only and since you are triggering all those things from publish you have the activation process also complete.

3 replies

Theo_Pendle
Level 8
August 13, 2019

Hi,

You could use a Resource Listener on your publisher to listen for changes in the JCR and send the emails accordingly. If you created your AEM project with a Maven archetype, it should have generated a SimpleResourceListener.java file for you. Check it out to see how it works. Basically, any time a resource is modified, a line is logged. Of course you could narrow down the listener (only to /content/your-project for example) and change it to send a mail instead.

Here is an example of a listener that implements EventHandler: acs-aem-samples/SampleSlingEventHandler.java at master · Adobe-Consulting-Services/acs-aem-samples · GitHub

August 14, 2019

But does this listener knows when page is completely replicated in target publish instance? As far as i know it will only listen to jcr node property update/add/remove etc. However jcr:lastReplicationAction is Activated also when you publish a page and it is in pending state so it doesn't gives conclusive evidence that the page is published to target instance.

Amit-Tiwari
Amit-TiwariAccepted solution
Level 4
August 14, 2019

I think you should write a workflow-

1.It should be triggered on modified event under /content/yourproject

2.it should be triggered on publish environment only

and from the workflow payload you will get the page details that you can use to send a mail from workflow only and since you are triggering all those things from publish you have the activation process also complete.