Search in sources :

Example 6 with ErrorInfo

use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.

the class JPAExecutorStoreService method removeError.

@Override
public ErrorInfo removeError(Long errorId) {
    ErrorInfo error = findError(errorId);
    commandService.execute(new RemoveObjectCommand(error));
    return error;
}
Also used : ErrorInfo(org.kie.api.executor.ErrorInfo) RemoveObjectCommand(org.jbpm.shared.services.impl.commands.RemoveObjectCommand)

Example 7 with ErrorInfo

use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.

the class ExecutorLogCleanTest method deleteErrorLogsByDate.

@Test
@BZ("1188702")
public void deleteErrorLogsByDate() throws Exception {
    CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(2);
    ((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
    KieSession ksession = createKSession(ASYNC_DATA_EXEC);
    WorkItemManager wim = ksession.getWorkItemManager();
    wim.registerWorkItemHandler("async", new AsyncWorkItemHandler(getExecutorService()));
    Map<String, Object> pm = new HashMap<String, Object>();
    pm.put("command", "org.jbpm.test.jobexec.UserFailingCommand");
    ProcessInstance pi = ksession.startProcess(ASYNC_DATA_EXEC_ID, pm);
    // Wait for the all retries to fail
    countDownListener.waitTillCompleted();
    // Assert completion of the job
    List<ErrorInfo> errorList = getExecutorService().getAllErrors(new QueryContext());
    Assertions.assertThat(errorList).hasSize(2);
    // Delete a record
    int resultCount = auditService.errorInfoLogDeleteBuilder().date(errorList.get(0).getTime()).build().execute();
    Assertions.assertThat(resultCount).isEqualTo(1);
    // Assert remaining records
    Assertions.assertThat(getExecutorService().getAllErrors(new QueryContext())).hasSize(1);
    // Abort running process instance
    ksession.abortProcessInstance(pi.getId());
}
Also used : ExecutorServiceImpl(org.jbpm.executor.impl.ExecutorServiceImpl) HashMap(java.util.HashMap) ErrorInfo(org.kie.api.executor.ErrorInfo) QueryContext(org.kie.api.runtime.query.QueryContext) CountDownAsyncJobListener(org.jbpm.test.listener.CountDownAsyncJobListener) AsyncWorkItemHandler(org.jbpm.executor.impl.wih.AsyncWorkItemHandler) KieSession(org.kie.api.runtime.KieSession) ProcessInstance(org.kie.api.runtime.process.ProcessInstance) WorkItemManager(org.kie.api.runtime.process.WorkItemManager) Test(org.junit.Test) BZ(qa.tools.ikeeper.annotation.BZ)

Example 8 with ErrorInfo

use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.

the class BasicExecutorIntegrationTest method executorExceptionTest.

@Test
public void executorExceptionTest() throws InterruptedException {
    CommandContext commandContext = new CommandContext();
    commandContext.setData("businessKey", UUID.randomUUID().toString());
    cachedEntities.put((String) commandContext.getData("businessKey"), new AtomicLong(1));
    commandContext.setData("callbacks", "org.jbpm.executor.ejb.impl.test.SimpleIncrementCallback");
    commandContext.setData("retries", 0);
    executorService.scheduleRequest("org.jbpm.executor.ejb.impl.test.ThrowExceptionCommand", commandContext);
    logger.info("{} Sleeping for 10 secs", System.currentTimeMillis());
    Thread.sleep(10000);
    List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
    assertEquals(1, inErrorRequests.size());
    logger.info("Error: {}", inErrorRequests.get(0));
    List<ErrorInfo> errors = executorService.getAllErrors(new QueryContext());
    logger.info("Errors: {}", errors);
    assertEquals(1, errors.size());
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) CommandContext(org.kie.api.executor.CommandContext) ErrorInfo(org.kie.api.executor.ErrorInfo) QueryContext(org.kie.api.runtime.query.QueryContext) RequestInfo(org.kie.api.executor.RequestInfo) Test(org.junit.Test)

Example 9 with ErrorInfo

use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.

the class BasicExecutorBaseTest method testCustomIncrementingRequestRetrySpecialValues.

@Test(timeout = 10000)
public void testCustomIncrementingRequestRetrySpecialValues() throws InterruptedException {
    CountDownAsyncJobListener countDownListener = configureListener(2);
    CommandContext ctxCMD = new CommandContext();
    ctxCMD.setData("businessKey", UUID.randomUUID().toString());
    ctxCMD.setData("retryDelay", "-1ms, 1m 80s");
    ctxCMD.setData("retries", 2);
    executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", ctxCMD);
    countDownListener.waitTillCompleted();
    List<ErrorInfo> errors = executorService.getAllErrors(new QueryContext());
    // 2 executions in total 1(regular) + 1(retry)
    assertEquals(2, errors.size());
    long firstError = errors.get(0).getTime().getTime();
    long secondError = errors.get(1).getTime().getTime();
    // Time difference between first and second shouldn't be bigger than 4 seconds as executor has 3 second interval and
    // should start executing second command immediately.
    long diff = secondError - firstError;
    assertTrue(diff < 4000);
    List<RequestInfo> allRequests = executorService.getAllRequests(new QueryContext());
    assertEquals(1, allRequests.size());
    // Future execution is planned to be started 2 minutes and 20 seconds after last fail.
    // Time difference vary because of test thread sleeping for 10 seconds.
    diff = allRequests.get(0).getTime().getTime() - Calendar.getInstance().getTimeInMillis();
    assertTrue(diff < 140000);
    assertTrue(diff > 130000);
    executorService.clearAllRequests();
}
Also used : CountDownAsyncJobListener(org.jbpm.executor.test.CountDownAsyncJobListener) CommandContext(org.kie.api.executor.CommandContext) ErrorInfo(org.kie.api.executor.ErrorInfo) QueryContext(org.kie.api.runtime.query.QueryContext) RequestInfo(org.kie.api.executor.RequestInfo) Test(org.junit.Test)

Example 10 with ErrorInfo

use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.

the class BasicExecutorIntegrationTest method defaultRequestRetryTest.

@Test
public void defaultRequestRetryTest() throws InterruptedException {
    CommandContext ctxCMD = new CommandContext();
    ctxCMD.setData("businessKey", UUID.randomUUID().toString());
    executorService.scheduleRequest("org.jbpm.executor.ejb.impl.test.ThrowExceptionCommand", ctxCMD);
    Thread.sleep(12000);
    List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
    assertEquals(1, inErrorRequests.size());
    List<ErrorInfo> errors = executorService.getAllErrors(new QueryContext());
    logger.info("Errors: {}", errors);
    // Three retries means 4 executions in total 1(regular) + 3(retries)
    assertEquals(4, errors.size());
}
Also used : CommandContext(org.kie.api.executor.CommandContext) ErrorInfo(org.kie.api.executor.ErrorInfo) QueryContext(org.kie.api.runtime.query.QueryContext) RequestInfo(org.kie.api.executor.RequestInfo) Test(org.junit.Test)

Aggregations

ErrorInfo (org.kie.api.executor.ErrorInfo)11 Test (org.junit.Test)10 QueryContext (org.kie.api.runtime.query.QueryContext)10 CommandContext (org.kie.api.executor.CommandContext)9 RequestInfo (org.kie.api.executor.RequestInfo)9 CountDownAsyncJobListener (org.jbpm.executor.test.CountDownAsyncJobListener)6 AtomicLong (java.util.concurrent.atomic.AtomicLong)4 HashMap (java.util.HashMap)1 ExecutorServiceImpl (org.jbpm.executor.impl.ExecutorServiceImpl)1 AsyncWorkItemHandler (org.jbpm.executor.impl.wih.AsyncWorkItemHandler)1 RemoveObjectCommand (org.jbpm.shared.services.impl.commands.RemoveObjectCommand)1 CountDownAsyncJobListener (org.jbpm.test.listener.CountDownAsyncJobListener)1 KieSession (org.kie.api.runtime.KieSession)1 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)1 WorkItemManager (org.kie.api.runtime.process.WorkItemManager)1 BZ (qa.tools.ikeeper.annotation.BZ)1