Ruleflow-Group and Rules order

724 views
Skip to first unread message

rab...@gmail.com

unread,
Apr 26, 2018, 5:50:35 AM4/26/18
to Drools Usage

Greetings,

 

we are a team of developers working with Drools 6.2.0 so far, we plan to upgrade to version 7.7.0 but unfortunately we have encountered the following problem:

 

we are working with BPMN 2.0 and for each task within the BPMN we set a Ruleflow-Group to fire certain rules – the rules of each task are dependent on the previous task‘s rules. I. e. the rules of a following task are only fired if the preceding task‘s rules have successfully provided the objects the following task‘s rules depend upon.

 

We ran our rule engine with Drools 7.7.0, but it does not work properly. – The produced results differ greatly from those produced by Drools 6.2.0. In 7.7.0, the rule order doesn‘t adhere to the order specified in the BPMN – it seems that the rules are fired in reverse or LIFO (last in, first out). Have we missed something that needs adjustment for the rules or Ruleflow-Group order to work properly (as specified in the BPMN)?

 

Note: for each individual rule, we DO NOT use "salience" or "auto-focus"

We use the following versions:

Drools 7.7.0 Final

kie-api 7.7.0 Final

jbpm-bpmn2 7.7.0 Final

Spring 4.1.4 Release

Java JDK 1.8.0_151

 

Example picture in the attachment:


Step A and Step A1 are in ruleflow-group "A"

Step B and Step B1 are in ruleflow-group "B"

Step C and Step C1 are in ruleflow-group "C"

 

output Drools 7.7.0

In BPMN the order is correct A -> B -> C

08:47:42,228 INFO  [stdout] (default task-5) startProcess

08:47:42,234 INFO  [stdout] (default task-5) BPMN --> A

08:47:42,235 INFO  [stdout] (default task-5) BPMN --> B

08:47:42,235 INFO  [stdout] (default task-5) BPMN --> C

08:47:42,236 INFO  [stdout] (default task-5) endProcess

 

After that the rules are fired but NOT in the right order (LIFO):

 

08:47:42,237 INFO  [stdout] (default task-5) null --> Step C1

08:47:42,238 INFO  [stdout] (default task-5) Step C1 --> Step C

08:47:42,239 INFO  [stdout] (default task-5) Step C --> Step B1

08:47:42,240 INFO  [stdout] (default task-5) Step B1 --> Step B

08:47:42,240 INFO  [stdout] (default task-5) Step B --> Step A

08:47:42,241 INFO  [stdout] (default task-5) Step A --> Step A1

 

output Drools 6.2.0

Here are BPMN and the rules fired together

 

09:04:55,747 INFO  [stdout] (default task-3) startProcess

09:04:55,788 INFO  [stdout] (default task-3) BPMN --> A

09:04:55,793 INFO  [stdout] (default task-3) endProcess

 

09:04:55,797 INFO  [stdout] (default task-3) null --> Step A

09:04:55,800 INFO  [stdout] (default task-3) Step A --> Step A1

 

09:04:55,806 INFO  [stdout] (default task-3) BPMN --> B

09:04:55,808 INFO  [stdout] (default task-3) Step A1 --> Step B

09:04:55,809 INFO  [stdout] (default task-3) Step B --> Step B1

 

09:04:55,811 INFO  [stdout] (default task-3) BPMN --> C

09:04:55,812 INFO  [stdout] (default task-3) Step B1 --> Step C

09:04:55,813 INFO  [stdout] (default task-3) Step C --> Step C1

 

Thanks for your support!


Example.PNG

Nicolas Héron

unread,
Apr 26, 2018, 6:01:06 AM4/26/18
to drools...@googlegroups.com
Hi,
Here you have added a listener for the process bpmn which displayed false ordering.
You should add the rule listener and you will see rules will be fired correctly
or Just add for each ruleflow group a rule like follows
ruleflow-group "A"
when
then
System.out.println("A");
end

same for the other rule flow group
and you will see the ruleflow group are correctly executed
Cheers
Nicolas


--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/735f3ea6-9e16-43f3-9566-5780ee308a9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rab...@gmail.com

unread,
Apr 26, 2018, 6:50:35 AM4/26/18
to Drools Usage

Hi Nicolas,


Thanks for your support!


but we do not have a listener in BPMN and we have add for each ruleflow group a rule like

Greetings
Hatem
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.

Nicolas Héron

unread,
Apr 26, 2018, 7:16:20 AM4/26/18
to drools...@googlegroups.com
can your put a zip containing a project example with a junit test ?

To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.

rab...@gmail.com

unread,
Apr 26, 2018, 8:10:01 AM4/26/18
to Drools Usage
there is an project example with the same problem:

rab...@gmail.com

unread,
May 2, 2018, 3:27:05 AM5/2/18
to Drools Usage
can anyone say something about it?

Alexandre Héroux

unread,
Jul 28, 2018, 2:37:33 PM7/28/18
to Drools Usage
I fall in the same error. Have you open a ticket about that?

Aparna

unread,
Aug 8, 2018, 9:42:07 AM8/8/18
to Drools Usage

jagan reddy

unread,
Aug 8, 2018, 10:25:18 AM8/8/18
to Drools Usage
hi

import org.kie.api.io.ResourceType;

import org.kie.api.runtime.process.ProcessInstance;

import org.kie.internal.KnowledgeBase;

import org.kie.internal.builder.KnowledgeBuilder;

import org.kie.internal.builder.KnowledgeBuilderFactory;

import org.kie.internal.io.ResourceFactory;

import org.kie.internal.runtime.StatefulKnowledgeSession;



public class RuleFlowUsingKieApi {



public static void main(String[] args) {

KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();

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

kbuilder.add(ResourceFactory.newClassPathResource("ruleflow.rf"), ResourceType.DRF);

KnowledgeBase kbase = kbuilder.newKnowledgeBase();

StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

// start a new process instance

Message message = new Message();

message.setMessage("Rule is fired");

message.setStatus(Message.HELLO);

ksession.insert(message);

ProcessInstance processInstance = ksession.startProcess("com.sample.ruleflow");

}

}


try this


Thanks

Jagan

Reply all
Reply to author
Forward
0 new messages