AsyncWorkItemHandler implements WorkItemHandler, Cacheable { @Override public void close() { } AsyncWorkItemHandler(ExecutorService executorService);  AsyncWorkItemHandler(ExecutorService executorService, String commandClass);  AsyncWorkItemHandler(Object executorService, String commandClass); @Override void executeWorkItem(WorkItem workItem, WorkItemManager manager); @Override void abortWorkItem(WorkItem workItem, WorkItemManager manager); @Override void close();  }
@Test(timeout=10000) public void testRunProcessWithAsyncHandlerDuplicatedRegister() throws Exception { final NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("Task 1", 1); RuntimeEnvironment environment = RuntimeEnvironmentBuilder.Factory.get().newDefaultBuilder() .userGroupCallback(userGroupCallback) .addAsset(ResourceFactory.newClassPathResource("BPMN2-ScriptTask.bpmn2"), ResourceType.BPMN2) .registerableItemsFactory(new DefaultRegisterableItemsFactory() { @Override public Map<String, WorkItemHandler> getWorkItemHandlers(RuntimeEngine runtime) { Map<String, WorkItemHandler> handlers = super.getWorkItemHandlers(runtime); handlers.put("async", new AsyncWorkItemHandler(executorService, "org.jbpm.executor.commands.PrintOutCommand")); return handlers; } @Override public List<ProcessEventListener> getProcessEventListeners( RuntimeEngine runtime) { List<ProcessEventListener> listeners = super.getProcessEventListeners(runtime); listeners.add(countDownListener); return listeners; } }) .get(); manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment); assertNotNull(manager); RuntimeEngine runtime = manager.getRuntimeEngine(EmptyContext.get()); KieSession ksession = runtime.getKieSession(); assertNotNull(ksession); ProcessInstance processInstance = ksession.startProcess("ScriptTask"); assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState()); countDownListener.waitTillCompleted(); processInstance = runtime.getKieSession().getProcessInstance(processInstance.getId()); assertNull(processInstance); manager.close(); manager = RuntimeManagerFactory.Factory.get().newSingletonRuntimeManager(environment); }