Expand my Community achievements bar.

SOLVED

Event Listener when a page gets replicated for every Agent

Avatar

Level 1

Hi,

Does anybody knows how to intercept the event when a page or node gets Activated or Deactivated but for a specific Agent ?

I know that you can have a Replication Event Listener but that one gets call after the page gets Activated and doesn't say to which replication Agent it was replicated to. 

I want to set a specific property in a page that gets Activated depending on the Agent that was sent to. Because the agents are triggered on different scenarios. 

I have been trying to inject a ReplicationListener Interface in the Preprocess but that didn't work .

Does anyone have an idea how to achieve this? or point me in the right direction ?

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 2

What I did to answer a similar requirement was to actual do it before it technically replicated. So this would depend whether or not you needed to capture the event when its actually being replicated vs when the workflow is sending it to the queue of the specified replication agent. I created a custom replication workflow step. Inside that step there is a loop that goes through all the selected replication agents and calls replicator.replicate(...). The replication agents are actually included in that call because they are added to the ReplicationOptions parameter This is very similar to how the OOTB ReplicatePageProcess step works. I then insert my code to update a set of custom properties with the time stamp of when the page/resource was sent and to which replication agent. I also include the actual user who ran the replication steps as well. This way I can use this for anything going through a workflow whether its a page, asset, or something else defined in a workflow package. 

I went this route because it was simpler to implement and there wasn't a client need to be 100% that the resource was already on a publish server. You could leverage a combination of my method and what the community article suggests and use your replication event listener to pull some temporary properties from the resource and update them when it was actually replicated.

View solution in original post

2 Replies

Avatar

Correct answer by
Level 2

What I did to answer a similar requirement was to actual do it before it technically replicated. So this would depend whether or not you needed to capture the event when its actually being replicated vs when the workflow is sending it to the queue of the specified replication agent. I created a custom replication workflow step. Inside that step there is a loop that goes through all the selected replication agents and calls replicator.replicate(...). The replication agents are actually included in that call because they are added to the ReplicationOptions parameter This is very similar to how the OOTB ReplicatePageProcess step works. I then insert my code to update a set of custom properties with the time stamp of when the page/resource was sent and to which replication agent. I also include the actual user who ran the replication steps as well. This way I can use this for anything going through a workflow whether its a page, asset, or something else defined in a workflow package. 

I went this route because it was simpler to implement and there wasn't a client need to be 100% that the resource was already on a publish server. You could leverage a combination of my method and what the community article suggests and use your replication event listener to pull some temporary properties from the resource and update them when it was actually replicated.

Avatar

Level 10

We do have a community article that explains how to build an event handler for replication events:

https://helpx.adobe.com/experience-manager/using/replication_events.html

However - it does not talk about how to setup to only respond to a specific replication agent. I will investigate this further to see if this is possible.