Search in sources :

Example 16 with AbstractRuntimeManager

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

the class ProcessInstanceAdminServiceImpl method acknowledgeError.

@Override
public void acknowledgeError(String... errorId) throws ExecutionErrorNotFoundException {
    for (String error : errorId) {
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("errorId", error);
        params.put("ack", new Short("0"));
        List<ExecutionError> execErrors = commandService.execute(new QueryNameCommand<List<ExecutionError>>("getErrorById", params));
        if (execErrors.isEmpty()) {
            throw new ExecutionErrorNotFoundException("No execution error found for id " + errorId);
        }
        ExecutionError errorInstance = execErrors.get(0);
        RuntimeManager runtimeManager = RuntimeManagerRegistry.get().getManager(errorInstance.getDeploymentId());
        if (runtimeManager != null) {
            ((AbstractRuntimeManager) runtimeManager).getExecutionErrorManager().getStorage().acknowledge(identityProvider.getName(), errorInstance.getErrorId());
        }
    }
}
Also used : ExecutionError(org.kie.internal.runtime.error.ExecutionError) HashMap(java.util.HashMap) ExecutionErrorNotFoundException(org.jbpm.services.api.admin.ExecutionErrorNotFoundException) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with AbstractRuntimeManager

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

the class ExecutionErrorHandlingRuntimeManagerTest method testBasicScriptFailure.

@Test
public void testBasicScriptFailure() {
    RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession1 = runtime1.getKieSession();
    assertNotNull(ksession1);
    try {
        ksession1.startProcess("BrokenScriptTask");
        fail("Start process should fail due to broken script");
    } catch (Throwable e) {
    // expected
    }
    manager.disposeRuntimeEngine(runtime1);
    ExecutionErrorManager errorManager = ((AbstractRuntimeManager) manager).getExecutionErrorManager();
    ExecutionErrorStorage storage = errorManager.getStorage();
    List<ExecutionError> errors = storage.list(0, 10);
    assertNotNull(errors);
    assertEquals(1, errors.size());
    assertExecutionError(errors.get(0), "Process", "BrokenScriptTask", "Hello");
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExecutionError(org.kie.internal.runtime.error.ExecutionError) ExecutionErrorManager(org.kie.internal.runtime.error.ExecutionErrorManager) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ExecutionErrorStorage(org.kie.internal.runtime.error.ExecutionErrorStorage) KieSession(org.kie.api.runtime.KieSession) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Example 18 with AbstractRuntimeManager

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

the class ExecutionErrorHandlingRuntimeManagerTest method testFailureAfterUserTaskNoWorkItemHandler.

@Test
public void testFailureAfterUserTaskNoWorkItemHandler() {
    RuntimeEngine runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get());
    KieSession ksession1 = runtime1.getKieSession();
    assertNotNull(ksession1);
    ProcessInstance pi = ksession1.startProcess("UserTaskWithCustomTask");
    manager.disposeRuntimeEngine(runtime1);
    runtime1 = manager.getRuntimeEngine(ProcessInstanceIdContext.get(pi.getId()));
    ksession1 = runtime1.getKieSession();
    TaskService taskService = runtime1.getTaskService();
    List<TaskSummary> tasks = taskService.getTasksAssignedAsPotentialOwner("john", "en-UK");
    assertEquals(1, tasks.size());
    long taskId = tasks.get(0).getId();
    taskService.start(taskId, "john");
    Map<String, Object> results = new HashMap<>();
    results.put("output1", "rollback");
    try {
        taskService.complete(taskId, "john", results);
        fail("Complete task should fail due to no work item handler found error");
    } catch (Throwable e) {
    // expected
    }
    manager.disposeRuntimeEngine(runtime1);
    ExecutionErrorManager errorManager = ((AbstractRuntimeManager) manager).getExecutionErrorManager();
    ExecutionErrorStorage storage = errorManager.getStorage();
    List<ExecutionError> errors = storage.list(0, 10);
    assertNotNull(errors);
    assertEquals(1, errors.size());
    assertExecutionError(errors.get(0), "Process", "UserTaskWithCustomTask", "Manual Task 2");
    String errorMessage = errors.get(0).getErrorMessage();
    assertTrue(errorMessage.contains("Could not find work item handler for Manual Task"));
}
Also used : RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExecutionError(org.kie.internal.runtime.error.ExecutionError) HashMap(java.util.HashMap) TaskService(org.kie.api.task.TaskService) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) ExecutionErrorManager(org.kie.internal.runtime.error.ExecutionErrorManager) TaskSummary(org.kie.api.task.model.TaskSummary) ExecutionErrorStorage(org.kie.internal.runtime.error.ExecutionErrorStorage) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AbstractBaseTest(org.jbpm.test.util.AbstractBaseTest) Test(org.junit.Test)

Aggregations

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