Search in sources :

Example 21 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class DefaultExecutionErrorStorage method acknowledge.

@Override
public void acknowledge(final String user, final String... errorIds) {
    if (!isActive()) {
        return;
    }
    call((EntityManager em) -> {
        for (String errorId : errorIds) {
            ExecutionError error = (ExecutionError) em.createQuery("from ExecutionErrorInfo where errorId =:errorId").setParameter("errorId", errorId).getSingleResult();
            error.setAcknowledged(true);
            error.setAcknowledgedBy(user);
            error.setAcknowledgedAt(new Date());
            em.merge(error);
        }
        return null;
    });
}
Also used : EntityManager(javax.persistence.EntityManager) ExecutionError(org.kie.internal.runtime.error.ExecutionError) Date(java.util.Date)

Example 22 with ExecutionError

use of org.kie.internal.runtime.error.ExecutionError in project jbpm by kiegroup.

the class ExecutionErrorHandlerImpl method handle.

@Override
public void handle(Throwable cause) {
    ExecutionErrorContext errorContext = new ExecutionErrorContext(cause, lastExecutedNode, lastExecutedTask, firstExecutedNode);
    for (ExecutionErrorFilter filter : filters) {
        if (filter.accept(errorContext)) {
            ExecutionError error = filter.filter(errorContext);
            logger.debug("Filter {} returned {} for {}", filter, error, cause);
            if (error != null) {
                try {
                    storage.store(error);
                    logger.debug("Error event {} stored successfully in {}", error, storage);
                } catch (Throwable e) {
                    logger.warn("Could not persist execution error {} due to {}", error, e.getMessage());
                    logger.debug("Stack trace ", e);
                }
            } else {
                logger.debug("Filter {} accepted error {} but didn't produce results (error should be ignored)", filter, cause);
            }
            return;
        }
    }
    // in case it ended up here - meaning not filters dealt with it, simply log the error
    logger.error("Unexpected error during processing ", cause);
}
Also used : ExecutionError(org.kie.internal.runtime.error.ExecutionError) ExecutionErrorContext(org.kie.internal.runtime.error.ExecutionErrorContext) ExecutionErrorFilter(org.kie.internal.runtime.error.ExecutionErrorFilter)

Aggregations

ExecutionError (org.kie.internal.runtime.error.ExecutionError)22 Test (org.junit.Test)14 ExecutionErrorStorage (org.kie.internal.runtime.error.ExecutionErrorStorage)14 KieSession (org.kie.api.runtime.KieSession)13 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)13 AbstractRuntimeManager (org.jbpm.runtime.manager.impl.AbstractRuntimeManager)12 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)10 ExecutionErrorManager (org.kie.internal.runtime.error.ExecutionErrorManager)10 HashMap (java.util.HashMap)9 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)8 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)8 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)7 ArrayList (java.util.ArrayList)6 List (java.util.List)5 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)5 AbstractBaseTest (org.jbpm.test.util.AbstractBaseTest)5 TaskService (org.kie.api.task.TaskService)5 TaskSummary (org.kie.api.task.model.TaskSummary)5 ExecutionErrorNotFoundException (org.jbpm.services.api.admin.ExecutionErrorNotFoundException)4 QueryContext (org.kie.api.runtime.query.QueryContext)4