roxy1987 [https://community.jboss.org/people/roxy1987] created the discussion
"Re: Invoke Human Task Flow - Using API" To view the discussion, visit: https://community.jboss.org/message/801956#801956 -------------------------------------------------------------- To start a process public static void startProc() throws Exception { try { KnowledgeBase kbase = readKnowledgeBase(); StatefulKnowledgeSession ksession = createKnowledgeSession(kbase); KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newThreadedFileLogger(ksession, "test", 1000); ksession.startProcess("com.sample.demoProc"); if(humanTaskHandler.isConnected()) { humanTaskHandler.dispose(); } System.out.println("Process started ..."); logger.close(); } catch (Throwable t) { t.printStackTrace(); } } private static KnowledgeBase readKnowledgeBase() throws Exception { KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder(); kbuilder.add(ResourceFactory.newClassPathResource("demoProc.bpmn"), ResourceType.BPMN2); return kbuilder.newKnowledgeBase(); } private static StatefulKnowledgeSession createKnowledgeSession(KnowledgeBase kbase) { StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession(); humanTaskHandler = new HornetQHTWorkItemHandler(ksession); humanTaskHandler.setIpAddress("localhost"); humanTaskHandler.setPort(5153); ksession.getWorkItemManager().registerWorkItemHandler("Human Task", humanTaskHandler); return ksession; } To complete a human task public static void completeTask(long taskId, String userId) throws Exception { String name = "client 1"+UUID.randomUUID(); TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler(); ContentData contentData = null; client.connect(ipAddress, port); try { client.start(taskId, userId, responseHandler); responseHandler = new BlockingTaskOperationResponseHandler(); responseHandler.waitTillDone(5000); client.complete(taskId, userId, contentData, responseHandler); responseHandler.waitTillDone(5000); BpmAPI.completeWorkItem(taskId); } catch(Exception e) { BpmExceptionHandler.handleException(e); } finally { if(client != null) { client.disconnect(); } } } To Pause/Suspend public static void completeTask(long taskId, String userId, Map<String, Object> map) throws Exception { String name = "client 1"+UUID.randomUUID(); TaskClient client = new TaskClient(new HornetQTaskClientConnector(name, new HornetQTaskClientHandler(SystemEventListenerFactory.getSystemEventListener()))); BlockingTaskOperationResponseHandler responseHandler = new BlockingTaskOperationResponseHandler(); client.connect(ipAddress, port); try { client.suspend(taskId, userId, responseHandler); responseHandler.waitTillDone(5000); } catch(Exception e) { BpmExceptionHandler.handleException(e); } finally { if(client != null) { client.disconnect(); } } } I dont use Guvnor so cant say about that. Regards. -------------------------------------------------------------- Reply to this message by going to Community [https://community.jboss.org/message/801956#801956] Start a new discussion in jBPM at Community [https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]
_______________________________________________ jboss-user mailing list jboss-user@lists.jboss.org https://lists.jboss.org/mailman/listinfo/jboss-user