Question

I am developing few rules on guvnor plugin. e.g. To check

  • The person is teacher.
  • The teacher is Male.
  • The Male teacher is of 45 years or above age.

I have all these 3 rules working separately. But now I want to call them in a sequence.

Like if the person is teacher. Insert new Fact MaleTeacher. Then in next rule populate the age of teacher in the received fact. Then check the age of teacher.

So how can I achieve this in drools-guvnor plugin.

I have created these rules using guided editor in drools-guvnor5.5 plugin jboss. Is there any option to create the chain of rules execution.

Any help much appreciated.

Was it helpful?

Solution

If you really need sequential invocation of rules please take a look at agenda-group and ruleflow-group topics in the documentation.

OTHER TIPS

It doesn't look like you need to force execution order. You just need to be writing the rules to match facts which are in the correct state.

A rule which matches a MaleTeacher will not activate until after a MaleTeacher has been inserted.

A rule to set the age of a MaleTeacher only needs to act upon MaleTeacher(age == null).

A rule which validates against the age of a MaleTeacher only needs to act upon MaleTeacher(age != null).

i.e. Don't try to force the order externally. Encode the business logic into the rules.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top