Expand my Community achievements bar.

What is alternative for ReplicationAction in AEMaaCS

Avatar

Level 3

I have a scenario where i trigger job in AEM Publish instance using ReplicationAction in on-prem, so now in AEMaaCS how to get replication object??

 

final ReplicationAction replicationAction = ReplicationEvent.fromEvent(event).getReplicationAction();
final ReplicationActionType actionType = replicationAction.getType();
final String FilePath = replicationAction.getPath();



i'm using the filePath to trigger job for removing the file/asset here.

 

could anyone guide me here that how to get path or file name while unpublishing/remove or publishing??

 

14 Replies

Avatar

Community Advisor

Hi @KarthickVe ,

You can publish/unpublish content using the Replication API in AEMaaCS -  API Documentation

Reference Link - https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/operations/repli...

So the same way should actually work as under the hood, AEMaaCS maps the replication actions (such as activate, deactivate) to corresponding Sling Content Distribution mechanisms.

 

Did you encounter any error when running the same program on AEMaaCS?

Avatar

Level 3

Hello@Rohan_Garg ,

you mean below code is valid is AEMaaCS as well??

final ReplicationAction replicationAction = ReplicationEvent.fromEvent(event).getReplicationAction();
final ReplicationActionType actionType = replicationAction.getType();
final String FilePath = replicationAction.getPath();

i thought its deprecated now or later as we have sling content distribution in place for AEMaaCS.

 

is it okay to use same code in cloud as well??

 

 

 

 

 

Avatar

Community Advisor

Yes, by maintaining the Replication API as a facade, AEMaaCS allows a smooth transition in moving from traditional AEM deployments to the cloud service, ensuring that custom replication logic and integrations continue to function correctly.

Avatar

Level 3

@Rohan_Garg , 

i'm trying to trigger this listener on the event of replication but its not triggering.

 

@Component(service = EventHandler.class, immediate = true, 
property = {
 AppConstants.SERVICE_DESCRIPTION + "=Replication Listener on publish",
 EventConstants.EVENT_TOPIC + "=" + "com/adobe/granite/replication"
 })
public class ReplicationListener implements EventHandler {
    private static final Logger LOG = LoggerFactory.getLogger(ReplicationListener.class);
    @Reference
    private JobManager jobManager;
 
    @Override
    public void handleEvent(final Event event) {
 
            final String METHOD_NAME = "handleEvent";
            final ReplicationAction replicationAction = ReplicationEvent.fromEvent(event).getReplicationAction();
            final ReplicationActionType actionType = replicationAction.getType();
            final String filePath = replicationAction.getPath();
 
}
}

Avatar

Community Advisor

@KarthickVe  You can use ReplicationAction.fromEvent(event).getPath() to get the resource path.

Avatar

Level 3

Hello @Harwinder-singhis it okay to use ReplicationAction.fromEvent(event).getPath() api code in cloud as well??

 

since AEMaaCs uses sling content distribution api so i'm having doubt here.

Avatar

Level 3

@Harwinder-singh ,

i'm trying to trigger this listener on the event of replication in publish environment but its not triggering. 

 

@Component(service = EventHandler.class, immediate = true, 
property = {
 AppConstants.SERVICE_DESCRIPTION + "=Replication Listener on publish",
 EventConstants.EVENT_TOPIC + "=" + "com/adobe/granite/replication"
 })
public class ReplicationListener implements EventHandler {
    private static final Logger LOG = LoggerFactory.getLogger(ReplicationListener.class);
    @Reference
    private JobManager jobManager;
 
    @Override
    public void handleEvent(final Event event) {
 
            final String METHOD_NAME = "handleEvent";
            final ReplicationAction replicationAction = ReplicationEvent.fromEvent(event).getReplicationAction();
            final ReplicationActionType actionType = replicationAction.getType();
            final String filePath = replicationAction.getPath();
 
}
}

Avatar

Community Advisor

@KarthickVe Can you please use com/day/cq/replication as event topic?

Avatar

Level 3

@Harwinder-singh This  com/day/cq/replication event will be used in author not works in publish. all the event handler not working in cloud. only event listener is working in cloud.

Avatar

Level 3

Hello @Harwinder-singh ,

 

i'm trying to trigger this listener on the event of replication but its not triggering.

 

@Component(service = EventHandler.class, immediate = true, 
property = {
 AppConstants.SERVICE_DESCRIPTION + "=Replication Listener on publish",
 EventConstants.EVENT_TOPIC + "=" + "com/adobe/granite/replication"
 })
public class ReplicationListener implements EventHandler {
    private static final Logger LOG = LoggerFactory.getLogger(ReplicationListener.class);
    @Reference
    private JobManager jobManager;
 
    @Override
    public void handleEvent(final Event event) {
 
            final String METHOD_NAME = "handleEvent";
            final ReplicationAction replicationAction = ReplicationEvent.fromEvent(event).getReplicationAction();
            final ReplicationActionType actionType = replicationAction.getType();
            final String filePath = replicationAction.getPath();
 
}
}

Avatar

Administrator

@KarthickVe Did you find the suggestions from users helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!



Kautuk Sahni