Expand my Community achievements bar.

SOLVED

Event handler for replication complete in AEM

Avatar

Level 1

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.

1 Accepted Solution

Avatar

Correct answer by
Level 4

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.

View solution in original post

3 Replies

Avatar

Level 10

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 ·...

Avatar

Level 1

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.

Avatar

Correct answer by
Level 4

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.