use of io.automatiko.engine.api.event.process.ProcessNodeInstanceFailedEvent in project automatiko-engine by automatiko-io.
the class ProcessEventSupport method fireAfterNodeInstanceFailed.
public void fireAfterNodeInstanceFailed(final ProcessInstance instance, NodeInstance nodeInstance, String errorId, String errorMessage, Exception exception, ProcessRuntime runtime) {
final Iterator<ProcessEventListener> iter = getEventListenersIterator();
final List<ProcessEventListener> delayedListeners = new ArrayList<ProcessEventListener>();
final ProcessNodeInstanceFailedEvent event = new ProcessNodeInstanceFailedEventImpl(instance, nodeInstance, errorId, errorMessage, exception, runtime);
if (iter.hasNext()) {
do {
ProcessEventListener listener = iter.next();
if (listener instanceof DelayedExecution) {
delayedListeners.add(listener);
} else {
listener.afterNodeInstanceFailed(event);
}
} while (iter.hasNext());
}
unitOfWorkManager.currentUnitOfWork().intercept(WorkUnit.create(event, (e) -> {
delayedListeners.forEach(l -> l.afterNodeInstanceFailed(e));
}));
}
Aggregations