Hi all,
I would like to create a replication listener for a defined path. The reason is I wouldn't like to fire the listener for each replication event, I am afraid about the performance of the author instance on production when replicating.
Any help?
Many thanks, Salva.
Solved! Go to Solution.
Views
Replies
Total Likes
THere is more information here:
http://blogs.adobe.com/experiencedelivers/experience-management/event_handling_incq/
But there does not look like there is a way to only fire on a path. Code:
@Component
@Service
@Property(name="event.topics",value= {ReplicationAction.EVENT_TOPIC, Example.EVENT_TOPIC})
public class ExampleEventHandler implements EventHandler {
Logger log = LoggerFactory.getLogger(this.getClass());
public void handleEvent(Event event) {
if (event.getTopic().equals(Example.EVENT_TOPIC)){
log.info("Example {}, with description {} has been created...",event.getProperty(Example.PN_NAME),event.getProperty(Example.PN_DESC));
} else if (event.getTopic().equals(ReplicationAction.EVENT_TOPIC)){
ReplicationAction action = ReplicationAction.fromEvent(event);
log.info("User {} has tried to replicate {}",action.getUserId(),action.getPath());
}
}
}
As stated - you can get the path and invoke app logic if a path is correct. But once the hanlder is installed and running - it will fire when ever a replication event occurs. That is - the Handler listens for all replication events.
Views
Replies
Total Likes
I could filter my application logic if event.getPath().contains(desiredPath) but I would like to fire a listener when replicating under a defined path.
Let's imagine I want to fire this event only for /path1/path2/path3 that means a 1% of the replications. (The other 99% of events fired are pointless)
Views
Replies
Total Likes
It deponds what you will be implementing in the listener. Should not be an issue if you followed best coding & is simple operation.
Views
Replies
Total Likes
If you need to restrict the amount of repository events you want to process directly on API level, JCR observation is the right thing for you. not possible with sling eventing. Read more details at https://cqdump.wordpress.com/2012/11/13/cq-coding-patterns-sling-vs-jcr-part-2/
Views
Replies
Total Likes
THere is more information here:
http://blogs.adobe.com/experiencedelivers/experience-management/event_handling_incq/
But there does not look like there is a way to only fire on a path. Code:
@Component
@Service
@Property(name="event.topics",value= {ReplicationAction.EVENT_TOPIC, Example.EVENT_TOPIC})
public class ExampleEventHandler implements EventHandler {
Logger log = LoggerFactory.getLogger(this.getClass());
public void handleEvent(Event event) {
if (event.getTopic().equals(Example.EVENT_TOPIC)){
log.info("Example {}, with description {} has been created...",event.getProperty(Example.PN_NAME),event.getProperty(Example.PN_DESC));
} else if (event.getTopic().equals(ReplicationAction.EVENT_TOPIC)){
ReplicationAction action = ReplicationAction.fromEvent(event);
log.info("User {} has tried to replicate {}",action.getUserId(),action.getPath());
}
}
}
As stated - you can get the path and invoke app logic if a path is correct. But once the hanlder is installed and running - it will fire when ever a replication event occurs. That is - the Handler listens for all replication events.
Views
Replies
Total Likes
Thanks,
This is the answer to my problem without solution ;)
Views
Replies
Total Likes
hey @salvadorm142499 i am also facing the same issue can please provide the solution for this
Views
Replies
Total Likes
Here is a community article that talks about how to build a Replication Event Handler.
http://helpx.adobe.com/experience-manager/using/replication_events.html
This lets you figure out the JCR path. If you have intense application logic - only invoke it if the JCR path is correct.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies