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

Programmatically know where page is being published (preview/publish)

Avatar

Level 2

Hi There,

 

We have a custom workflow, which indexes a published page to Search Index (External). However when a user previews a page it indexes page to search index. We are already using `getAgentId` function from AgentConfig instance but Agent Config is always null even when both preview and publish replication agent instances are configured.

replicationAction.getConfig().getAgentId()

 

Using `Event` class's `getProperty()` returns all replication agent Ids 

event.getProperty("agentIds")

 

Is there any other way to know which instance given page is being published to preview or publish

 

1 Accepted Solution

Avatar

Correct answer by
Level 2

Hi There,

 

I would like to answer my question as I found a (probable) solution and its working for us. Instead of relying on AgentConfig

ReplicationAction.fromEvent(event).getConfig()

We are relying on Event config agentIds

 

List <String> agentIds = (List<String>) event.getProperty("agentIds");
agentIds.contains("publish");

agentIds from Event objects contains all agentIds on which page is going to be replicated and activated

 

Thanks

  

View solution in original post

5 Replies

Avatar

Community Advisor

I don't fully understand what you are asking, but here are some thoughts that may be useful:

- The replication configuration is static, meaning that you will know exactly how many replication agents you have and how/when any of these will be used. For example, if you run a workflow or activate a page you will know prior hand to which environment the page will be published.

- You can actually get the replication agents programmatically by using Agent Manager API https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/index.html?com/day/cq...

- A page does not let any trace of to which information it was "deliver", you can check this form ore details  https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/replicatio... . But if you need to track if a page was published to one specific server you need to customize that action, either you add a property upon activation or you can check if the node is present in the target server. 

 

Hope this helps.



Esteban Bustamante

Avatar

Level 2

Hi  @EstebanBustamante

 

In gist, I just want to know if page being activated is activated to publish server or preview server from event instance or ReplicationAction instance. 

Avatar

Community Advisor

Hi @bagwanpankaj There's no way you can find out if a page is published to specific server/instance. For that you need to run queries in specific servers(publish) then probably reverse replicate to author and then index it based on what you get back.

 

Thanks

-Bilal

Avatar

Correct answer by
Level 2

Hi There,

 

I would like to answer my question as I found a (probable) solution and its working for us. Instead of relying on AgentConfig

ReplicationAction.fromEvent(event).getConfig()

We are relying on Event config agentIds

 

List <String> agentIds = (List<String>) event.getProperty("agentIds");
agentIds.contains("publish");

agentIds from Event objects contains all agentIds on which page is going to be replicated and activated

 

Thanks

  

Avatar

Level 3

If i understood your issue, you have different replication agents for live publishers and preview publishers. There is an option for authors to only publish content to preview publishers and when that happens your custom workflow is updating search index. If all this what i mentioned is true, how is custom workflow getting triggered? Is it configured to trigger whenever a page is published? If yes, then go to preview publish replication agent and on "Triggers" tab select "No status update" checkbox. This will ensure that your page when published to preview server will not get updated with replication status which should in turn not trigger your custom workflow. Hope this helps!