AEM 6.5 : How to make event listener not wait for an event to complete
Hi,
We have a requirement to listen on the node additions in a particular jcr path and do some processing on the added nodes by calling our custom java code whenever an event happens. The scenario is like, say a node is added in AEM, the listener listens on the event and calls custom java code to do further processing and until this processing is complete, the listener is waiting. So the listener completes one event and then moves on to the second. It's a while loop on the event iterator.
We want that the listener should hand over the processing of event to custom java code and move on to the next event and not wait for the java code processing to be over.
We considered jobs but it using jobs was ruled out as we want the code processing to be in real time without any delay and that's why we want parallel processing.
How can we achieve that with an event listener?
Thanks
Code snippet:
public void onEvent(EventIterator events) {
while(events.hasNext()) {
Event nextEvent = events.nextEvent();
try{
//custom java code called here
} catch (RepositoryException e) {
log.error("RepositoryException occurred", e);
}
}
}