Package org.nuxeo.ecm.core.event.impl
Class AbstractLongRunningListener
- java.lang.Object
-
- org.nuxeo.ecm.core.event.impl.AbstractLongRunningListener
-
- All Implemented Interfaces:
PostCommitEventListener,PostCommitFilteringEventListener
public abstract class AbstractLongRunningListener extends Object implements PostCommitFilteringEventListener
Abstract class that helps building an Asynchronous listeners that will handle a long running process.By default,
PostCommitEventListenerare executed in aWorkthat will take care of starting/comitting the transaction.If the listener requires a long processing this will create long transactions that are not good. To avoid this behavior, this base class split the processing in 3 steps :
- pre processing : transactional first step
- long running : long running processing that should not require transactional resources
- post processing : transactional final step
To manage sharing between the 3 steps, a simple Map is provided.
- Since:
- 5.7.2
- Author:
- Tiry
-
-
Constructor Summary
Constructors Constructor Description AbstractLongRunningListener()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidhandleEvent(EventBundle events)Handles the set of events that were raised during the life of an user operation.protected abstract booleanhandleEventLongRunning(List<String> eventNames, Map<String,Object> data)Will be executed in a non transactional contextprotected abstract voidhandleEventPostprocessing(EventBundle events, Map<String,Object> data)Finish processing in a dedicated Transactionprotected abstract booleanhandleEventPreprocessing(EventBundle events, Map<String,Object> data)Handles first step of processing in a normal transactional way.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.nuxeo.ecm.core.event.PostCommitFilteringEventListener
acceptEvent
-
-
-
-
Field Detail
-
log
protected static final Log log
-
-
Method Detail
-
handleEvent
public void handleEvent(EventBundle events)
Description copied from interface:PostCommitEventListenerHandles the set of events that were raised during the life of an user operation.The events are fired as a
BundleEventafter the transaction is committed.- Specified by:
handleEventin interfacePostCommitEventListener- Parameters:
events- the events to handle
-
handleEventPreprocessing
protected abstract boolean handleEventPreprocessing(EventBundle events, Map<String,Object> data)
Handles first step of processing in a normal transactional way.- Parameters:
events-EventBundlereceiveddata- an empty map to store data to share data between steps.- Returns:
- true of processing should continue, false otherwise
-
handleEventLongRunning
protected abstract boolean handleEventLongRunning(List<String> eventNames, Map<String,Object> data)
Will be executed in a non transactional contextAny access to a CoreSession will generate WARN in the the logs.
Documents passed with data should not be connected.
- Parameters:
eventNames- list of event namesdata- an map that may have been filled by handleEventPreprocessing- Returns:
- true of processing should continue, false otherwise
-
handleEventPostprocessing
protected abstract void handleEventPostprocessing(EventBundle events, Map<String,Object> data)
Finish processing in a dedicated Transaction- Parameters:
events-EventBundlereceiveddata- an map that may have been filled by handleEventPreprocessing and handleEventLongRunning
-
-