[jboss-user] [jBPM] - About jBPM5.1 ProcessInstance and HumanTask persisit

Gao jie do-not-reply at jboss.com
Sun Oct 9 05:53:05 EDT 2011


Gao jie [http://community.jboss.org/people/super_man.sh] created the discussion

"About jBPM5.1 ProcessInstance and HumanTask persisit"

To view the discussion, visit: http://community.jboss.org/message/630762#630762

--------------------------------------------------------------
Dear All,

I'm use MySQL for persist ProcessInstance and ProcessInstance and HumanTask Object.This is the code:


 
public static final void main(String[] args) {
     TaskClient taskClient = new TaskClient(new MinaTaskClientConnectorExt("MinaConnector",
               new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
     taskClient.connect("127.0.0.1", 9123);
     //init datasource.......
     KnowledgeBase kbase = readKnowledgeBase();               
     EntityManagerFactory emf =Persistence.createEntityManagerFactory("org.jbpm.jpa" );
     Environment env = KnowledgeBaseFactory.newEnvironment();
     env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
     env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());
     // create a new knowledge session that uses JPA to store the runtime state
     
     StatefulKnowledgeSession ksession = JPAKnowledgeService.newStatefulKnowledgeSession(kbase, null, env );
     //StatefulKnowledgeSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(1, kbase, null, env);
     //StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();
     
        WSHumanTaskHandler taskHandler=new WSHumanTaskHandler();
        taskHandler.setClient(taskClient);
        ksession.getWorkItemManager().registerWorkItemHandler("Human Task", taskHandler);
        Map params = new HashMap();
        params.put("userId", "krisv");
        params.put("description", "Need a new laptop computer");
        ksession.startProcess("com.sample.humantask", params);
 
     ksession.dispose();
     taskClient.disconnect();
}
 


This main methd execute is ok,then I found ProcessInstance and Human info is in MySQL(in sessioninfo and task tables).Next,I write complete the task code as below:

public static final void main(String[] args) {
          TaskClient taskClient = new TaskClient(new MinaTaskClientConnectorExt("MinaConnector",
                    new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
          taskClient.connect("127.0.0.1", 9123);
 
 
          //init datasource......
  
          KnowledgeBase kbase = readKnowledgeBase(); 
          EntityManagerFactory emf =Persistence.createEntityManagerFactory("org.jbpm.jpa" );
          Environment env = KnowledgeBaseFactory.newEnvironment();
          env.set( EnvironmentName.ENTITY_MANAGER_FACTORY, emf );
          env.set(EnvironmentName.TRANSACTION_MANAGER, TransactionManagerServices.getTransactionManager());
          // create a new knowledge session that uses JPA to store the runtime state
  
          StatefulKnowledgeSession ksession = JPAKnowledgeService.loadStatefulKnowledgeSession(1, kbase, null, env);
          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);
          ksession.signalEvent("Signal",null);
          ksession.dispose();
          taskClient.disconnect();
}
 


Execute the code,The task will be completed.
I want to the ProcessInstance Continue to flow after task complete.So I write 
| 
 | ksession.signalEvent("Signal",null); |
But the processInstance not continue to flow, Please help me!
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/630762#630762]

Start a new discussion in jBPM at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20111009/bfac9f3e/attachment-0001.html 


More information about the jboss-user mailing list