Jack G [
http://community.jboss.org/people/super_man.sh] created the discussion
"Re: About jBPM5.1 ProcessInstance and HumanTask persisit"
To view the discussion, visit:
http://community.jboss.org/message/631013#631013
--------------------------------------------------------------
Hey Mauricio,
Thanks for reply,I have already change my code as follows:
public static final void startProcess() {
TaskClient taskClient = new TaskClient(new
MinaTaskClientConnectorExt("MinaConnector",
new
MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
taskClient.connect("127.0.0.1", 9123);
KnowledgeBase kbase = readKnowledgeBase();
EntityManagerFactory emf
=Persistence.createEntityManagerFactory("org.jbpm.jpa" );
Environment env = KnowledgeBaseFactory.newEnvironment();
env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf);
env.set(EnvironmentName.GLOBALS, new MapGlobalResolver());
env.set(EnvironmentName.TRANSACTION_MANAGER,
TransactionManagerServices.getTransactionManager());
env.set(EnvironmentName.OBJECT_MARSHALLING_STRATEGIES, new
ObjectMarshallingStrategy[]{new JPAPlaceholderResolverStrategy(env),new
SerializablePlaceholderResolverStrategy(ClassObjectMarshallingStrategyAcceptor.DEFAULT)});
StatefulKnowledgeSession ksession =
JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env );
CommandBasedWSHumanTaskHandler taskHandler=new
CommandBasedWSHumanTaskHandler(ksession);
taskHandler.setClient(taskClient);
ksession.getWorkItemManager().registerWorkItemHandler("Human Task",
taskHandler);
ksession.startProcess("com.sample.humantask");
}
The first Human Task was generated after execute the startProcess method, then I write the
method completeTask1 as follows:
public static final void completeTask1() {
TaskClient taskClient = new TaskClient(new
MinaTaskClientConnectorExt("MinaConnector",
new
MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
taskClient.connect("127.0.0.1", 9123);
BlockingTaskSummaryResponseHandler taskSummaryHandler = new
BlockingTaskSummaryResponseHandler();
List<String> groups = new ArrayList<String>();
groups.add("sales");
taskClient.getTasksAssignedAsPotentialOwner("sales-rep", groups,
"en-UK", taskSummaryHandler);
TaskSummary task1 = taskSummaryHandler.getResults().get(0);
BlockingTaskOperationResponseHandler taskOperationHandler = new
BlockingTaskOperationResponseHandler();
taskClient.claim(task1.getId(), "sales-rep", groups, taskOperationHandler);
taskOperationHandler = new BlockingTaskOperationResponseHandler();
taskClient.start(task1.getId(), "sales-rep", taskOperationHandler);
taskOperationHandler.waitTillDone(1000);
taskOperationHandler = new BlockingTaskOperationResponseHandler();
Map<String, Object> results = new HashMap<String, Object>();
results.put("comment", "Agreed, existing laptop needs replacing");
results.put("outcome", "Accept");
ContentData contentData = new ContentData();
contentData.setAccessType(AccessType.Inline);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream out;
try {
out = new ObjectOutputStream(bos);
out.writeObject(results);
out.close();
contentData = new ContentData();
contentData.setContent(bos.toByteArray());
contentData.setAccessType(AccessType.Inline);
} catch (IOException e) {
e.printStackTrace();
}
taskClient.complete(task1.getId(), "sales-rep", contentData,
taskOperationHandler);
taskOperationHandler.waitTillDone(1000);
}
Execute the completeTask1 method,first Human Task was be completed in db,but the
processinstance was not continue,task table screenshot as follows:
http://community.jboss.org/servlet/JiveServlet/showImage/2-631013-17115/t...
http://community.jboss.org/servlet/JiveServlet/downloadImage/2-631013-171...
As you see,the first HumanTask status was completed,because processinstance was not
continue,so no new HumanTask generate.If continue the processInstance will be generate new
HumanTask.But there is no.I don't know why.
Thanks & Best Regards
--------------------------------------------------------------
Reply to this message by going to Community
[
http://community.jboss.org/message/631013#631013]
Start a new discussion in jBPM at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=1&...]