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;
}
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());
}
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());
}
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();
}
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());
}
Aggregations