use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method testPrioritizedJobsExecution.
@Test(timeout = 10000)
public void testPrioritizedJobsExecution() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(2);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", "low priority");
ctxCMD.setData("priority", 2);
Date futureDate = new Date(System.currentTimeMillis() + EXTRA_TIME);
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", futureDate, ctxCMD);
CommandContext ctxCMD2 = new CommandContext();
ctxCMD2.setData("businessKey", "high priority");
ctxCMD2.setData("priority", 8);
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", futureDate, ctxCMD2);
countDownListener.waitTillCompleted();
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(2, executedRequests.size());
RequestInfo executedHigh = executedRequests.get(1);
assertNotNull(executedHigh);
assertEquals("high priority", executedHigh.getKey());
RequestInfo executedLow = executedRequests.get(0);
assertNotNull(executedLow);
assertEquals("low priority", executedLow.getKey());
assertTrue(executedLow.getTime().getTime() > executedHigh.getTime().getTime());
}
use of org.kie.api.executor.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method testProcessContextJobsExecution.
@Test(timeout = 10000)
public void testProcessContextJobsExecution() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(1);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", "low priority");
ctxCMD.setData("deploymentId", "not-deployed-here");
ctxCMD.setData("processInstanceId", 2L);
Long requestId = executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
List<STATUS> statuses = Arrays.asList(STATUS.QUEUED);
List<RequestInfo> byDeploymentRequests = executorService.getRequestsByDeployment("not-deployed-here", statuses, new QueryContext());
assertEquals(1, byDeploymentRequests.size());
List<RequestInfo> byProcessInstanceRequests = executorService.getRequestsByProcessInstance(2L, statuses, new QueryContext());
assertEquals(1, byProcessInstanceRequests.size());
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(1, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(0, executedRequests.size());
countDownListener.waitTillCompleted(5000);
inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(1, queuedRequests.size());
executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(0, executedRequests.size());
executorService.cancelRequest(requestId);
}
use of org.kie.api.executor.RequestInfo 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.RequestInfo in project jbpm by kiegroup.
the class BasicExecutorBaseTest method reoccurringExecutionTest.
@Test(timeout = 10000)
public void reoccurringExecutionTest() throws InterruptedException {
CountDownAsyncJobListener countDownListener = configureListener(3);
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", UUID.randomUUID().toString());
executorService.scheduleRequest("org.jbpm.executor.commands.ReoccurringPrintOutCommand", ctxCMD);
countDownListener.waitTillCompleted();
List<RequestInfo> rescheduled = executorService.getRequestsByBusinessKey((String) ctxCMD.getData("businessKey"), Arrays.asList(STATUS.QUEUED), new QueryContext());
assertEquals(1, rescheduled.size());
executorService.cancelRequest(rescheduled.get(0).getId());
List<RequestInfo> inErrorRequests = executorService.getInErrorRequests(new QueryContext());
assertEquals(0, inErrorRequests.size());
List<RequestInfo> queuedRequests = executorService.getQueuedRequests(new QueryContext());
assertEquals(0, queuedRequests.size());
List<RequestInfo> executedRequests = executorService.getCompletedRequests(new QueryContext());
assertEquals(3, executedRequests.size());
}
use of org.kie.api.executor.RequestInfo 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());
}
Aggregations