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,
PostCommitEventListener
are executed in aWork
that 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 void
handleEvent(EventBundle events)
Handles the set of events that were raised during the life of an user operation.protected abstract boolean
handleEventLongRunning(List<String> eventNames, Map<String,Object> data)
Will be executed in a non transactional contextprotected abstract void
handleEventPostprocessing(EventBundle events, Map<String,Object> data)
Finish processing in a dedicated Transactionprotected abstract boolean
handleEventPreprocessing(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:PostCommitEventListener
Handles the set of events that were raised during the life of an user operation.The events are fired as a
BundleEvent
after the transaction is committed.- Specified by:
handleEvent
in 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
-EventBundle
receiveddata
- 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
-EventBundle
receiveddata
- an map that may have been filled by handleEventPreprocessing and handleEventLongRunning
-
-