Search in sources :

Example 6 with ExecutorServiceImpl

use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.

the class AsyncWorkItemHandlerTest method testRunProcessWithAsyncHandlerRecordExecutionError.

@Test(timeout = 10000)
public void testRunProcessWithAsyncHandlerRecordExecutionError() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
    ((ExecutorServiceImpl) executorService).addAsyncJobListener(countDownListener);
    ((ExecutorServiceImpl) executorService).setRetries(0);
    RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder().userGroupCallback(userGroupCallback).addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2).registerableItemsFactory(new DefaultRegisterableItemsFactory() {

        @Override
        public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) {
            Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime);
            handlers.put("async", new AsyncWorkItemHandler(executorService, "org.jbpm.executor.ThrowExceptionCommand"));
            return handlers;
        }
    }).get();
    manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment);
    assertNotNull(manager);
    RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get());
    KieSession ksession = runtime.getKieSession();
    assertNotNull(ksession);
    ProcessInstance processInstance = ksession.startProcess("ScriptTask");
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    countDownListener.waitTillCompleted();
    processInstance = runtime.getKieSession().getProcessInstance(processInstance.getId());
    assertNotNull(processInstance);
    List<RequestInfo> errorJobs = executorService.getInErrorRequests(new QueryContext());
    assertEquals(1, errorJobs.size());
    RequestInfo errorJob = errorJobs.get(0);
    assertEquals(errorJob.getProcessInstanceId().longValue(), processInstance.getId());
    ExecutionErrorManager errorManager = ((AbstractRuntimeManager) manager).getExecutionErrorManager();
    assertNotNull("ErrorManager is null", errorManager);
    ExecutionErrorStorage errorStorage = errorManager.getStorage();
    assertNotNull("ErrorStorage is null", errorStorage);
    List<ExecutionError> errors = errorStorage.list(0, 10);
    assertEquals(1, errors.size());
    ExecutionError error = errors.get(0);
    assertNotNull(error);
    assertEquals("Job", error.getType());
    assertEquals(errorJob.getId(), error.getJobId());
    assertEquals("ScriptTask", error.getProcessId());
    assertEquals("", error.getActivityName());
    assertEquals(manager.getIdentifier(), error.getDeploymentId());
    assertNotNull(error.getError());
    assertNotNull(error.getErrorMessage());
    assertNotNull(error.getActivityId());
    assertNotNull(error.getProcessInstanceId());
    assertNull(error.getAcknowledgedAt());
    assertNull(error.getAcknowledgedBy());
    assertFalse(error.isAcknowledged());
}
Also used : DefaultRegisterableItemsFactory(org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) ExecutionError(org.kie.internal.runtime.error.ExecutionError) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) RuntimeEnvironment(org.kie.api.runtime.manager.RuntimeEnvironment) AbstractRuntimeManager(org.jbpm.runtime.manager.impl.AbstractRuntimeManager) QueryContext(org.kie.api.runtime.query.QueryContext) RequestInfo(org.kie.api.executor.RequestInfo) WorkItemHandler(org.kie.api.runtime.process.WorkItemHandler) CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) ExecutionErrorManager(org.kie.internal.runtime.error.ExecutionErrorManager) ExecutionErrorStorage(org.kie.internal.runtime.error.ExecutionErrorStorage) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) AbstractExecutorBaseTest(org.jbpm.test.util.AbstractExecutorBaseTest) Test(org.junit.Test)

Example 7 with ExecutorServiceImpl

use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.

the class CleanupExecutionErrorCommandWithProcessTest method configureListener.

protected CountDownAsyncJobListener configureListener(int threads) {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(threads);
    ((ExecutorServiceImpl) executorService).addAsyncJobListener(countDownListener);
    return countDownListener;
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl)

Example 8 with ExecutorServiceImpl

use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.

the class CleanupLogCommandWithProcessTest method configureListener.

protected CountDownAsyncJobListener configureListener(int threads) {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(threads);
    ((ExecutorServiceImpl) executorService).addAsyncJobListener(countDownListener);
    return countDownListener;
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl)

Example 9 with ExecutorServiceImpl

use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.

the class BasicExecutorBaseTest method configureListener.

protected CountDownAsyncJobListener configureListener(int threads) {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(threads);
    ((ExecutorServiceImpl) executorService).addAsyncJobListener(countDownListener);
    return countDownListener;
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl)

Example 10 with ExecutorServiceImpl

use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.

the class ReconfiguredExecutorTest method configureListener.

protected CountDownAsyncJobListener configureListener(int threads) {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(threads);
    ((ExecutorServiceImpl) executorService).addAsyncJobListener(countDownListener);
    return countDownListener;
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl)

Aggregations

ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)32 Test (org.junit.Test)24 KieSession (org.kie.api.runtime.KieSession)18 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)17 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)16 HashMap (java.util.HashMap)13 CountDownAsyncJobListener (org.jbpm.test.listener.CountDownAsyncJobListener)13 QueryContext (org.kie.api.runtime.query.QueryContext)12 AbstractExecutorBaseTest (org.jbpm.test.util.AbstractExecutorBaseTest)8 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)8 RuntimeEnvironment (org.kie.api.runtime.manager.RuntimeEnvironment)8 DefaultRegisterableItemsFactory (org.jbpm.runtime.manager.impl.DefaultRegisterableItemsFactory)6 WorkItemHandler (org.kie.api.runtime.process.WorkItemHandler)6 AsyncWorkItemHandler (org.jbpm.executor.impl.wih.AsyncWorkItemHandler)5 AbstractRuntimeManager (org.jbpm.runtime.manager.impl.AbstractRuntimeManager)5 RequestInfo (org.kie.api.executor.RequestInfo)5 NodeLeftCountDownProcessEventListener (org.jbpm.test.listener.NodeLeftCountDownProcessEventListener)4 CommandContext (org.kie.api.executor.CommandContext)4 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)4 TaskSummary (org.kie.api.task.model.TaskSummary)4