Hi,
I'm working on this replication listener to capture events on my publish instance whenever DAM assets are published in our author instance.
This replication listener is used to filter paths and if matches our desired filters, it will also trigger replication to other publisher.
Basically, our setup is:
When activating a cq:page:
AUTHORING (author) ==> STAGING (publish).
Then activate from STAGING (publish) ==> LIVE (publish)
When activating/deactivating a dam:Asset
AUTHOR ==> STAGING
AUTHOR ==> LIVE
Sample code below:
@Component(
label = "Replication Event Listener",
description = "Listen to replication events and relay it to publisher if necessary.",
metatype = false
)
@Properties({
// Scope the paths as tightly as possible based on your use-case.
@Property(
label = "Topic",
description = "Event topic for replication",
name = EventConstants.EVENT_TOPIC,
value = ReplicationAction.EVENT_TOPIC
)
})
@Service
public class ReplicationEventListener implements EventHandler {
private Logger log = LoggerFactory.getLogger(this.getClass());
@Override
public void handleEvent(Event event) {
String n[] = event.getPropertyNames();
log.info("");
log.info("Event occurred: {}", event.getProperty(WorkflowEvent.EVENT_TYPE));
log.info("Event properties: ");
for (String s : n) {
log.info(s + " = " + event.getProperty(s));
}
action = ReplicationAction.fromEvent(event);
if (action != null) {
log.info("Replication action {} occured on {} ", action.getType().getName(), action.getPath());
}
log.info("");
}
}