Search in sources :

Example 1 with ExecutionErrorInfo

use of org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo in project jbpm by kiegroup.

the class DefaultExecutionErrorStorage method store.

@Override
public ExecutionError store(ExecutionError error) {
    if (!isActive()) {
        return error;
    }
    return call((EntityManager em) -> {
        ExecutionErrorInfo errorEntity = new ExecutionErrorInfo(error.getErrorId(), error.getType(), error.getDeploymentId(), error.getProcessInstanceId(), error.getProcessId(), error.getActivityId(), error.getActivityName(), error.getJobId(), error.getErrorMessage(), error.getError(), error.getErrorDate(), error.getInitActivityId());
        em.persist(errorEntity);
        return error;
    });
}
Also used : EntityManager(javax.persistence.EntityManager) ExecutionErrorInfo(org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo)

Example 2 with ExecutionErrorInfo

use of org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo in project jbpm by kiegroup.

the class AutoAckErrorCommand method execute.

@Override
public ExecutionResults execute(CommandContext ctx) throws Exception {
    ExecutionResults executionResults = new ExecutionResults();
    String emfName = (String) ctx.getData("EmfName");
    if (emfName == null) {
        emfName = "org.jbpm.domain";
    }
    String singleRun = (String) ctx.getData("SingleRun");
    if ("true".equalsIgnoreCase(singleRun)) {
        // disable rescheduling
        this.nextScheduleTimeAdd = -1;
    }
    String nextRun = (String) ctx.getData("NextRun");
    if (nextRun != null) {
        nextScheduleTimeAdd = DateTimeUtils.parseDateAsDuration(nextRun);
    }
    // get hold of persistence and create instance of audit service
    EntityManagerFactory emf = EntityManagerFactoryManager.get().getOrCreate(emfName);
    EntityManager em = emf.createEntityManager();
    try {
        List<ExecutionErrorInfo> errorsToAck = findErrorsToAck(em);
        logger.debug("Found {} jobs that can be auto ack", errorsToAck.size());
        errorsToAck.forEach(error -> {
            AbstractRuntimeManager manager = (AbstractRuntimeManager) RuntimeManagerRegistry.get().getManager(error.getDeploymentId());
            if (manager != null) {
                ExecutionErrorManager errorManager = manager.getExecutionErrorManager();
                errorManager.getStorage().acknowledge("SYSTEM", error.getErrorId());
                logger.debug("Error {} has been auto acknowledged by system based on {}", error.getErrorId(), getAckRule());
            } else {
                logger.warn("Unable to ack error {} due missing runtime manager for '{}'", error.getErrorId(), error.getDeploymentId());
            }
        });
    } finally {
        em.close();
    }
    return executionResults;
}
Also used : EntityManager(javax.persistence.EntityManager) ExecutionErrorInfo(org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo) ExecutionResults(org.kie.api.executor.ExecutionResults) ExecutionErrorManager(org.kie.internal.runtime.error.ExecutionErrorManager) EntityManagerFactory(javax.persistence.EntityManagerFactory) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager)

Aggregations

EntityManager (javax.persistence.EntityManager)2 ExecutionErrorInfo (org.jbpm.runtime.manager.impl.jpa.ExecutionErrorInfo)2 EntityManagerFactory (javax.persistence.EntityManagerFactory)1 AbstractRuntimeManager (org.jbpm.runtime.manager.impl.AbstractRuntimeManager)1 ExecutionResults (org.kie.api.executor.ExecutionResults)1 ExecutionErrorManager (org.kie.internal.runtime.error.ExecutionErrorManager)1