Hi @keerthi0555 ,
This will not work because the way you define filter is not correct for Replication Event. This EventHandler framework has different way of defining property values for different Event. Instead of using path please use paths So just to answer your question add filter as below.
property = {
EventConstants.EVENT_TOPIC + "=" + ReplicationAction.EVENT_TOPIC,
EventConstants.EVENT_FILTER +"=("+ReplicationEvent.PATHS+"=/content/mdt/Regions/*)",
}) or like this
property = {
EventConstants.EVENT_TOPIC + "=" + ReplicationAction.EVENT_TOPIC,
EventConstants.EVENT_FILTER +"=(paths=/content/mdt/Regions/*)",
}) Sharing a working ReplicationEventhandler for your reference. Adjust code per your need.
import com.day.cq.replication.ReplicationAction;
import com.day.cq.replication.ReplicationActionType;
import com.day.cq.replication.ReplicationEvent;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventConstants;
import org.osgi.service.event.EventHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Component(service = EventHandler.class,
immediate = true,
property = {
EventConstants.EVENT_TOPIC + "=" + ReplicationAction.EVENT_TOPIC,
EventConstants.EVENT_FILTER +"=("+ ReplicationEvent.PATHS+"=/content/mdt/Regions/*)",
})
public class ReplicationEventHandler implements EventHandler {
private static final Logger LOG = LoggerFactory.getLogger(ReplicationEventHandler.class);
public void handleEvent(final Event event) {
try {
LOG.info("\n Event Type : {} ", event.getTopic());
if (ReplicationAction.fromEvent(event).getType().equals(ReplicationActionType.ACTIVATE)) {
LOG.info("\n Page Published : {}", ReplicationAction.fromEvent(event).getPath());
}
if (ReplicationAction.fromEvent(event).getType().equals(ReplicationActionType.DEACTIVATE)) {
LOG.info("\n Page Deactivated : {}", ReplicationAction.fromEvent(event).getPath());
}
}catch (Exception e){
LOG.error("\n Error while Activating/Deactivating - {} " , e.getMessage());
}
}
}Check ReplicationEvent documentation for reference.