Here is an example that shows how to process a loop using JBPM5.

A simple example shown in the discussion is considered here.

This example has two parameters ‘count’ and ‘loopcondition’.

The paramter ‘count’ gets incremented in a loop until it is less than a ‘loopcondition’.


ScreenHunter_09 Mar. 01 09.41.gif


ScreenHunter_05 Mar. 01 20.34.gif

How to run this example?


This example has a bpmn file (looptest777.bpmn) and a test file ( It might be easy to start with a HelloProcess project ( and import these files.


ScreenHunter_03 Mar. 01 20.16.gif


Here is the sample test code. The main process ‘looptest777’  is started as shown below.



public static final void main(String[] args) {
  try {
   // load up the knowledge base
   KnowledgeBase kbase = readKnowledgeBase();
   StatefulKnowledgeSession ksession = createSession(kbase);
   KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory
     .newFileLogger(ksession, "test");

   // set the parameters
   Map<String, Object> params = new HashMap<String, Object>();
   params.put("count", 1);
   params.put("loopcondition", 3);
   // start a new process instance
   ksession.startProcess("looptest777", params);
  } catch (Throwable t) {


Following output can be seen after running the example.

ScreenHunter_04 Mar. 01 20.18.gif