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

Best practice to trigger some code after publish


Level 5

When a user publishes a product collection I need to trigger some code to push this data out of AEM into our Product Collection DynamoDB Table. I wanted to check what is the best practice for this would be (We are using AEM 6.2). From what I can tell I would want a sling event to capture the replication event (filtered based on path in the repository) and then I could either run my code to update DynamoDB or create a Sling Job(?) that from what I understand effectively places this on a queue that means I can then have my DynamoDB update code reading from this Job queue to give me more confidence that this code will be executed. My understanding is that it makes sense to run this on the author so I don't have n publishers all triggering the same thing but I want to ensure this code is run when the replication is successful I'm hopeful that the event is only triggered after success?

0 Replies


Level 8


One way I could think of is to have the logic to capture data into the db table, along with the logic [after the mentioned logic is processed]where you are replicating concerned stuff takes place. This way you need not have to explicitly listen to replication events and trigger capture of data into DB


Level 10

What about a Publish Workflow where you could write a custom step that is invoked as part of the Publish Workflow. I know we do that internally.


Level 7


if you try to use a ReplicationListener i think that you are sure that the element is already published on the publish instance.

I put here a snippet that I use for my project:

package com.adobe.cq.listeners;


public class MyReplicationHandler implements ReplicationListener {

   public void onStart(Agent agent, ReplicationAction replicationAction) {


   public void onMessage(ReplicationLog.Level level, String s) {

   //put in the queue

   public void onEnd(Agent agent, ReplicationAction replicationAction, ReplicationResult replicationResult) {


   public void onError(Agent agent, ReplicationAction replicationAction, Exception e) {



Let us know.