JBoss Community

Re: Creating process dynamically using Fluent API

created by Kris Verlaenen in jBPM Development - View the full discussion

Hi,

 

Could you share how you then try to load this process into your knowledge base?

 

To be able to execute a process, it should also be "compiled", which means that we need to do some additional processing in some cases (like for example the script node) to make sure we can execute it as fast as possible.  The easiest way to do this is to just use one of the kbuilder methods to load the process.  In this case, you can do:

 

RuleFlowProcess process = factory.validate().getProcess();
System.out.println(XmlBPMNProcessDumper.INSTANCE.dump(process));
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
kbuilder.add(ResourceFactory.newByteArrayResource(XmlBPMNProcessDumper.INSTANCE.dump(process).getBytes()), ResourceType.BPMN2);
KnowledgeBase kbase = kbuilder.newKnowledgeBase();

 

For a full example, see here:

https://github.com/droolsjbpm/jbpm/blob/master/jbpm-bpmn2/src/test/java/org/jbpm/bpmn2/ProcessFactoryTest.java

 

Kris

Reply to this message by going to Community

Start a new discussion in jBPM Development at Community