cancel
Showing results for 
Search instead for 
Did you mean: 

BusinessRuleTask - deploy error

rdenner
Champ in-the-making
Champ in-the-making
Hi,

I want to use the new BusinessRuleTask element for a test.
I defined a rule (drl) file, which I include in the Business Archive (bar).
I modeled a simple process and two forms. The BusinessRuleTask
executes 2 rules, gets 2 input variables and delivers 1 result variable.

Here is an example of one of my rules:


rule "salarycheck"

when
    (salary > 3000) && (age < 30)
then
    ruleOutput = "pattern1";
end

I wanted to deploy the bar file, but I get the error:
java.lang.NoClassDefFoundError: org/drools/runtime/rule/AgendaFilter

Do I need the Drools package for working with the BusinessRuleTask?
Does anyone have a simple example?

Thanks & Regards,
Rainer.
33 REPLIES 33

mikedias
Champ in-the-making
Champ in-the-making
Hi Tijs!

I think that the Process Variables could be inserted into Drools together with the Input Variables. So, you can combine your beans and the Process Variables in your rules.

My objective is allow writing business rules without Java code.

Thanks!

mikedias
Champ in-the-making
Champ in-the-making
Hi,

I added this in the BusinessRuleTaskActivityBehavior.java:


ksession.insert(execution.getVariables());
And the rule below works fine:


import java.util.Map;

rule "ChoseGroup"
when
   Map( this["actionType"] == "tech" )
then
  System.out.println("The group chosen is engineering");
  insert("engineering");
end
In the "Candidate Group" of the next task, I assign ${ruleOutput} and this works too.

But I have 2 questions:
1) All the objects inserted in the ksession go to output variable. Could I to send only the output produced by the rule? This is a good approach?
2) The use of BusinessRuleTask is a better approach to dynamically choose users or groups based in a decision table? My problem is: given a process variable, choose the user / group based in a rule that can be changed any time.

tombaeyens
Champ in-the-making
Champ in-the-making
In many processes, there are a lot of process variables, some of which can be large.  With the implementation you propose, all the process variable data has to be fetched from the DB and deserialized into objects.  Even if none of these variables are used, all that overhead is performed.

I suppose there is a workaround for accessing variables in the current implementation as well.

If I recall correct, there is a way to implement lazy loading of these variables in drools.  I think it might be through something called global variables in drools, but it's been a while since I checked that out.  A solution that includes lazy loading would be a nice contribution.

tombaeyens
Champ in-the-making
Champ in-the-making
The solution to customize the drools globals so that you can do lazy loading of the variables can be done with this api i believe:

knowledgeRuntime.getGlobals().setDelegate(customGlobalsImplWithLazyLoadingOfVariables);
http://docs.jboss.org/jbpm/v5.1/javadocs/org/drools/runtime/Globals.html#setDelegate(org.drools.runt...

mikedias
Champ in-the-making
Champ in-the-making
Interesting Tom, but the Drools have some restrictions about the globals:

"Globals are not inserted into the Working Memory, and therefore a global should never be used to establish conditions in rules except when it has a constant immutable value. The engine cannot be notified about value changes of globals and does not track their changes. Incorrect use of globals in constraints may yield surprising results - surprising in a bad way."
http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html/ch04.html#d0e4482

I think that the variables in the rule scope is immutable, but I don't have sure.

bernd_ruecker
Champ in-the-making
Champ in-the-making
Hi Mike.

You can (at kleast since 5.10) attach a expression or delegate to the Business Rule Task. We consider it best practice to implement your own delegate to steer Drools, then you have full control over what you are doing and can easily encapsulate it behind some service interface or the like… Then you can insert all data you want 🙂

mikedias
Champ in-the-making
Champ in-the-making
Hi Bernd, thanks for answer!

In my Activiti Eclipse Designer 5.9.3 I can't see this option. The delegate can be assigned in the "Input variables" field?

However, I think that the process variables should be accessible for all rules in any situation. Then we have more options to build a complex rule without effort.

bernd_ruecker
Champ in-the-making
Champ in-the-making
Hi Mike.

From the engine point of view it looks still like a service task: http://svn.codehaus.org/activiti/activiti/trunk/modules/activiti-engine/src/test/resources/org/activ....

For the Activiti Designer I actually do not know as we use a different eclipse designer (https://app.camunda.com/confluence/display/foxUserGuide/fox+designer) 😉

Sorry & cheers
Bernd

trademak
Star Contributor
Star Contributor
Hi Mike,

Yes I think we could add an attribute to the business rule task to copy all process variables to the Drools context.
I disagree with Bernd that a service task is the best option. Of course you can implement it exactly as you want in that case, but you also need more Drools knowledge.

Best regards,

bernd_ruecker
Champ in-the-making
Champ in-the-making
Hi Tijs.

I think if you use Drools you need Drools Know-How, there is no way around it. And the API is easy enough to do that, the problem normally is the DRL/Excel/SDL whatever syntax… And the current implementation is too limit for real live use cases in my opinion, but I still think that is not an issue, since you can implement it yourself in the way you want to have it. Perfectly fine 🙂

But OK, we do not have to reach some sort of agreement, that is what we recommend and we actually do not support the Drools implementation of the Business Rule Task in the EE version of fox…

Cheers
Bernd