Hi @daniel-strmecki ,
Nothing special. Just simple steps to start OSGi component on publisher.
1. Created OSGi service:
@Component(
service = EventHandler.class,
property = {
"event.topics=com/day/cq/replication"
},
configurationPolicy = ConfigurationPolicy.REQUIRE,
immediate = true
)
@Designate(ocd = MyReplicationEventListener.Configuration.class)
public class MyReplicationEventListener implements EventHandler {
2. Created OSGi configuration and put in under config.publish to start this component only on publisher.
Of course, I has this condition in this listener to handle event only on leader POD:
if (!discoveryService.getTopology().getLocalInstance().isLeader()) {
log.info("Skipping event {} because it's not a leader.", event);
return;
}
According to the logs, it caught replication events on AEMaaCS publisher.
Thank you for the code example. I was looking for it. I read that recently they have fixed Flush Rules for the AEMaaCS. I am going to try this approach.
I tried to re-implement according to ACS Commons Dispatcher Flush Rules implementation for cloud.
They build their logic on author environment by listening of org/apache/sling/distribution/agent/package/distributed.
However, I realized that can't properly handle such events on author instance. I have a logic to handle replicated paths with /etc/map and resource.resolver.mapping on publisher and I don't want to apply these mappings on author instance as well.
I modified my event listener and now it's listening com/adobe/granite/replication instead of com/day/cq/replication. This setup works for me as well.
Besides of that, I am sure that initial implementation worked as expected, but event handler was black-listed by reaching 5s timeout.