JBoss Community

Re: JBPM5 Starting Guvnor process question

created by npereira in jBPM - View the full discussion

Hi forum,

 

I'm still having some dificulty with his question, I was wondering if someone could help.

 

What we are trying to implement is a startProcess() method.

The objective of this method is to contact the runtime engine and “tell it” to start a given process, without using REST.

 

So far we have gotten to these point.

 

KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.newKnowledgeAgentConfiguration();

KnowledgeAgent kagent = KnowledgeAgentFactory.newKnowledgeAgent("testKAgent", aconf);    

String fileName = "/home/n1w3/Downloads/ChangeSet.xml";

kagent.applyChangeSet(ResourceFactory.newFileResource(fileName));

KnowledgeBase kbase = kagent.getKnowledgeBase();

 

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

Collection<ProcessInstance> c = ksession.getProcessInstances();

 

System.out.println(c.size());

kbase = kagent.getKnowledgeBase();

for (Process process: kbase.getProcesses()) {

System.out.println("Loading process from Guvnor: " + process.getId());

}

 

  ksession.getWorkItemManager().registerWorkItemHandler("Human Task", new WSHumanTaskHandler());

//StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();           

ProcessInstance processInstance = ksession.startProcess("com.temenos.bpmn.CustomerOnBoarding");

 

System.out.println(processInstance.getId());

 

These peace of code, lets us fetch the processes that are in guvnor and then start a new process.

The problem with it, is that I have to maintain my session open so that the process gets orchestrated. If I stop the program, the process does not get orchestrated.

 

The objective we are trying to obtain is something like a “fire and forget” approach where we say start process and the runtime engine orchestrates it.

 

Can anybody help us out with this one?

Reply to this message by going to Community

Start a new discussion in jBPM at Community