Here is an example that shows how to use 'Rule Task' component with a process.

A simple example shown in is considered here to illustrate the feature.


This example has a loop condition which is determined using the rules based on the location of the user and the starting condition.


ScreenHunter_03 Mar. 07 14.14.gif

'LoopConditionRules' is a 'Rule Task' component and it needs to have a valid RuleFlowGroup name (e.g.,  EvalLoopcondistion as shown below).


ScreenHunter_04 Mar. 07 14.14.gif

The RuleFlowGroup set in the previous step has to match with the 'ruleflow-group' name in the 'drl' rules file as shown below.



ScreenHunter_05 Mar. 07 14.15.gif


Here is the sample test code to start the process after setting the initial parameters.


          // 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>();

            HelloProcessModel hpm = new HelloProcessModel();

            hpm.setCount(new Integer("3"));


            params.put("hpm", hpm);






Note that the 'drl' rules file needs to be added to the knowledgebase as shown below.


private static KnowledgeBase readKnowledgeBase() throws Exception {


                .setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());


                .setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl());


                .setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());


                .setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());

        KnowledgeBuilder kbuilder = KnowledgeBuilderFactory





         * Add drl file


        kbuilder.add(ResourceFactory.newClassPathResource("LoopConditionRules.drl"), ResourceType.DRL);

        return kbuilder.newKnowledgeBase();



How to run this example?


This example has a bpmn file (processRuleslooptest777.bpmn), model file (, rules file (LoopConditionRules.drl) and a test file ( It might be easy to start with a HelloProcess project ( and import these files.



ScreenHunter_08 Mar. 07 14.43.gif


Following results can be seen after successfully running the example.

ScreenHunter_07 Mar. 07 14.18.gif