use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method defaultRequestRetryTest.
@Test(timeout = 10000)
public void defaultRequestRetryTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(4);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(1, inErrorRequests.size());
RequestInfo failedJob = inErrorRequests.get(0);
assertEquals(4, failedJob.getExecutions());
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());
}
use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method executorExceptionTrimmingTest.
@Test(timeout = 10000)
public void executorExceptionTrimmingTest() throws InterruptedException {
System.setProperty("org.kie.executor.msg.length", "10");
System.setProperty("org.kie.executor.stacktrace.length", "20");
CountDownAsyncJobListener countDownListener = configureListener(1);
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.SimpleIncrementCallback");
commandContext.setData("retries", 0);
executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", commandContext);
logger.info("{} Sleeping for 10 secs", System.currentTimeMillis());
countDownListener.waitTillCompleted();
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());
ErrorInfo error = errors.get(0);
assertEquals(10, error.getMessage().length());
assertEquals(20, error.getStacktrace().length());
}
use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method executorExceptionTest.
@Test(timeout = 10000)
public void executorExceptionTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(1);
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.SimpleIncrementCallback");
commandContext.setData("retries", 0);
executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", commandContext);
logger.info("{} Sleeping for 10 secs", System.currentTimeMillis());
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(1, inErrorRequests.size());
logger.info("Error: {}", inErrorRequests.get(0));
assertEquals(1, inErrorRequests.get(0).getExecutions());
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 testCustomConstantRequestRetry.
@Test(timeout = 10000)
public void testCustomConstantRequestRetry() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(3);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
ctxCMD.setData("retryDelay", "2s");
ctxCMD.setData("retries", 2);
executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(1, inErrorRequests.size());
RequestInfo failedJob = inErrorRequests.get(0);
assertEquals(3, failedJob.getExecutions());
List<ErrorInfo> errors = executorService.getAllErrors(new QueryContext());
// Three retries means 4 executions in total 1(regular) + 2(retries)
assertEquals(3, errors.size());
long firstError = errors.get(0).getTime().getTime();
long secondError = errors.get(1).getTime().getTime();
long thirdError = errors.get(2).getTime().getTime();
// time difference between first and second should be at least 3 seconds
long diff = secondError - firstError;
assertTrue(diff > 2000);
// time difference between second and third should be at least 6 seconds
diff = thirdError - secondError;
assertTrue(diff > 2000);
}
use of org.kie.api.executor.ErrorInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method testCustomIncrementingRequestRetry.
@Test(timeout = 10000)
public void testCustomIncrementingRequestRetry() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(3);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
ctxCMD.setData("retryDelay", "3s, 6s");
ctxCMD.setData("retries", 2);
executorService.scheduleRequest("org.jbpm.executor.ThrowExceptionCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(1, inErrorRequests.size());
List<ErrorInfo> errors = executorService.getAllErrors(new QueryContext());
// Three retries means 4 executions in total 1(regular) + 3(retries)
assertEquals(3, errors.size());
long firstError = errors.get(0).getTime().getTime();
long secondError = errors.get(1).getTime().getTime();
long thirdError = errors.get(2).getTime().getTime();
// time difference between first and second should be at least 3 seconds
long diff = secondError - firstError;
assertTrue(diff > 3000);
// time difference between second and third should be at least 6 seconds
diff = thirdError - secondError;
assertTrue(diff > 6000);
}
Aggregations