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 a
Work
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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
handleEvent
(EventBundle events) Handles the set of events that were raised during the life of an user operation.protected abstract boolean
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
-
Constructor Details
-
AbstractLongRunningListener
public AbstractLongRunningListener()
-
-
Method Details
-
handleEvent
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
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
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
Finish processing in a dedicated Transaction- Parameters:
events
-EventBundle
receiveddata
- an map that may have been filled by handleEventPreprocessing and handleEventLongRunning
-