Event handling can be done in different ways within CQ, that all have their cost, their impact, and their benefits.
To view the current snapshot of events you should check the events logs at http://host:port/system/console/events.
We can achieve event handling at sling level by implementing EventHandler interface in a class.
We can achieve event handling at JCR level by implementing EventListener interface in a class. JCR Observer is the lowest-level event handling in CQ. As its name indicates it, is at JCR level and allows to listen to JCR-level events, gathered in sets (corresponding to persistence transactions). javax.jcr.observation.Event lists following types:
The ObservationManager object acquired via Workspace.getObservationManager(). Allows for the registration and deregistration of event listeners.Observation Manager Api is omni present in AEM. 200 thousand event it can handle in entire life time. It has methods like :-
|Event handler||Event listener|
|It is at the Sling level with event handlers and jobs||It is at the JCR level with observation.|
|org.osgi.service.event.EventHandler interface||javax.jcr.observation.EventListener interface|
|override handleEvent(Event) method.||override onEvent(EventIterator ) method|
Event subscriber need to subscribe event.topic property to an Event Handler in the OSGi Event Admin service.