Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

How to push a node from author to publish in real time on Adobe Cloud ?

Avatar

Level 3

I am working on AEM project to be deployed on Adobe cloud. I have a requirement that whenever a store data node of nt:unstructured type say "store1" on the path /content/data/stores/store1 is created in JCR on author, it should be pushed on publish instance as well automatically. I guess we can use sling content distribution (forward distribution) to achieve this ? Do I need to write any code to sync these changes from author to publish in real time ?
For example this is how I am saving a node on author using a servlet

 

Node rootNode = session.getNode("/content/data/stores");
storeNode = rootNode.addNode(storeId, "nt:unstructured");
// Set created date
Calendar created = Calendar.getInstance();
storeNode.setProperty("jcr:created", created);

Now I want to this new store node to be available on publish instance too in real time. Kindly guide regarding this.

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor
5 Replies

Avatar

Correct answer by
Community Advisor

Avatar

Level 3

@arunpatidar So I need to do following two steps ? 

  1. Listener to listen changes (Will it work on adobe cloud)
  2. Use Replication API (I need to use replication API code in my servlet to push node changes from author to publish ) ?

Avatar

Community Advisor

Hi @touseefk2181136 
If you are creating those nodes using servlet then you don't need Listener then you can use Replication API to replicate node.

 



Arun Patidar

Avatar

Employee

@touseefk2181136 

Since you are creating the node programatically on author, you can even publish it from author to publisher in code itself using replication api

replicator.replicate(session, ReplicationActionType.ACTIVATE, "your_path");

Avatar

Community Advisor

@touseefk2181136  You need to add the below after setting the node properties.

 

replicator.replicate(session, ReplicationActionType.ACTIVATE, "/content/data/stores");

 

Ofcourse, make sure that you add the Replicator service in your service by using : 

@Reference
    private Replicator replicator;

More on the replication API - https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/operations/repli...