use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.
the class SLATrackingCommandTest method configureListener.
protected CountDownAsyncJobListener configureListener(int threads) {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(threads);
((ExecutorServiceImpl) executorService).addAsyncJobListener(countDownListener);
return countDownListener;
}
use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.
the class JmsAvaiableJobExecutorTest method testAsyncAuditProducerPrioritizedJobs.
@Test
public void testAsyncAuditProducerPrioritizedJobs() throws Exception {
CountDownAsyncJobListener countDownListener = configureListener(2);
final List<String> executedJobs = new ArrayList<String>();
((ExecutorServiceImpl) executorService).addAsyncJobListener(new AsynchronousJobListener() {
@Override
public void beforeJobScheduled(AsynchronousJobEvent event) {
}
@Override
public void beforeJobExecuted(AsynchronousJobEvent event) {
}
@Override
public void beforeJobCancelled(AsynchronousJobEvent event) {
}
@Override
public void afterJobScheduled(AsynchronousJobEvent event) {
}
@Override
public void afterJobExecuted(AsynchronousJobEvent event) {
executedJobs.add(event.getJob().getKey());
}
@Override
public void afterJobCancelled(AsynchronousJobEvent event) {
}
});
CommandContext ctxCMD = new CommandContext();
ctxCMD.setData("businessKey", "low priority");
ctxCMD.setData("priority", 2);
CommandContext ctxCMD2 = new CommandContext();
ctxCMD2.setData("businessKey", "high priority");
ctxCMD2.setData("priority", 8);
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD);
executorService.scheduleRequest("org.jbpm.executor.commands.PrintOutCommand", ctxCMD2);
ut.commit();
MessageReceiver receiver = new MessageReceiver();
receiver.receiveAndProcess(queue, countDownListener);
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());
assertEquals(2, executedJobs.size());
assertEquals("high priority", executedJobs.get(0));
assertEquals("low priority", executedJobs.get(1));
}
use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.
the class ExecutorServiceFactory method configure.
private static ExecutorService configure(EntityManagerFactory emf, TransactionalCommandService commandService, ExecutorEventSupportImpl eventSupport) {
// create instances of executor services
ExecutorQueryService queryService = new ExecutorQueryServiceImpl(true);
Executor executor = new ExecutorImpl();
ExecutorAdminService adminService = new ExecutorRequestAdminServiceImpl();
ExecutorStoreService storeService = new JPAExecutorStoreService(true);
((JPAExecutorStoreService) storeService).setCommandService(commandService);
((JPAExecutorStoreService) storeService).setEmf(emf);
((JPAExecutorStoreService) storeService).setEventSupport(eventSupport);
AvailableJobsExecutor jobExecutor = new AvailableJobsExecutor();
ClassCacheManager classCacheManager = new ClassCacheManager();
jobExecutor.setClassCacheManager(classCacheManager);
jobExecutor.setQueryService(queryService);
jobExecutor.setExecutorStoreService(storeService);
jobExecutor.setEventSupport(eventSupport);
jobExecutor.setExecutor(executor);
((ExecutorImpl) executor).setExecutorStoreService(storeService);
((ExecutorImpl) executor).setEventSupport(eventSupport);
((ExecutorImpl) executor).setJobProcessor(jobExecutor);
((ExecutorImpl) executor).setTransactionManager(commandService.getTransactionManager());
// set executor on all instances that requires it
((ExecutorQueryServiceImpl) queryService).setCommandService(commandService);
((ExecutorRequestAdminServiceImpl) adminService).setCommandService(commandService);
((ExecutorRequestAdminServiceImpl) adminService).setExecutor(executor);
// configure services
ExecutorService service = new ExecutorServiceImpl(executor);
((ExecutorServiceImpl) service).setQueryService(queryService);
((ExecutorServiceImpl) service).setExecutor(executor);
((ExecutorServiceImpl) service).setAdminService(adminService);
((ExecutorServiceImpl) service).setEventSupport(eventSupport);
return service;
}
use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.
the class LogCleanupCommandTest method skipTaskLog.
@Ignore
@Test(timeout = 10000)
public void skipTaskLog() throws Exception {
KieSession kieSession = null;
List<ProcessInstance> processInstanceList = null;
try {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
// Generate data
kieSession = createKSession(LOG_CLEANUP);
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("assigneeName", "krisv");
processInstanceList = startProcess(kieSession, LOG_CLEANUP_ID, paramMap, 1);
TaskService taskService = getRuntimeEngine().getTaskService();
List<Long> taskIdList = taskService.getTasksByProcessInstanceId(processInstanceList.get(0).getId());
taskService.start(taskIdList.get(0), "krisv");
taskService.complete(taskIdList.get(0), "krisv", null);
// Verify presence of data
Assertions.assertThat(getProcessLogSize(LOG_CLEANUP_ID)).isEqualTo(1);
Assertions.assertThat(getTaskLogSize(LOG_CLEANUP_ID)).isEqualTo(1);
Assertions.assertThat(getNodeInstanceLogSize(LOG_CLEANUP_ID)).isPositive();
Assertions.assertThat(getVariableLogSize(LOG_CLEANUP_ID)).isEqualTo(3);
// Schedule cleanup job
scheduleLogCleanup(false, true, false, getTomorrow(), null, LOG_CLEANUP_ID);
countDownListener.waitTillCompleted();
// Verify absence of data
Assertions.assertThat(getProcessLogSize(LOG_CLEANUP_ID)).isZero();
Assertions.assertThat(getTaskLogSize(LOG_CLEANUP_ID)).isEqualTo(1);
Assertions.assertThat(getNodeInstanceLogSize(LOG_CLEANUP_ID)).isZero();
Assertions.assertThat(getVariableLogSize(LOG_CLEANUP_ID)).isZero();
} finally {
if (processInstanceList != null) {
abortProcess(kieSession, processInstanceList);
}
}
}
use of org.jbpm.executor.impl.ExecutorServiceImpl in project jbpm by kiegroup.
the class LogCleanupCommandTest method deleteAllLogsOlderThanTomorrowDifferentProcess.
@Test(timeout = 10000)
public void deleteAllLogsOlderThanTomorrowDifferentProcess() throws Exception {
CountDownAsyncJobListener countDownListener = new CountDownAsyncJobListener(1);
((ExecutorServiceImpl) getExecutorService()).addAsyncJobListener(countDownListener);
deleteAllLogsOlderThan(getTomorrow(), HELLO_WORLD_ID, ANOTHER_PROCESS, countDownListener);
Assertions.assertThat(getProcessLogSize(HELLO_WORLD_ID)).isPositive();
Assertions.assertThat(getNodeInstanceLogSize(HELLO_WORLD_ID)).isPositive();
}
Aggregations