cancel
Showing results for 
Search instead for 
Did you mean: 

RulesDeployer: What should happen if there are no rules?

njames
Champ in-the-making
Champ in-the-making
Hi,

I am trying to introduce Drools rules into my current processes. My process currently has a UserTask to manually approve a request. I am looking to add a BusinessRuleTask before it that would only allow the rules to circumvent the UserTask, effectively "auto-approving" the request.

I would like to allow the rules to be custom, but I have a problem in that the RulesDeployer only creates the KnowledgeBase if one or more rules are deployed. If there are no rules deployed, the process fails because it has no KnowledgeBase. My question is "shouldn't the RulesDeployer (or more likely the RulesHelper)  create the KnowledgeBase even if there are no rules"?

      knowledgeBase = (KnowledgeBase) knowledgeBaseCache.get(deploymentId);
      if (knowledgeBase==null) {
        throw new ActivitiException("deployment "+deploymentId+" doesn't contain any rules");
      }

My argument is that the process can allow the possibility of providing business rules without having to have a base "vanilla" "not-approved" rule just to make sure that the KnowledgeBase is created. ( I am more than a little worried about being able to remove the base rule, if some better rules are provided).

Any thoughts, anyone?

Thanks,

Nick.
7 REPLIES 7

trademak
Star Contributor
Star Contributor
Hi,

So are you saying that you don't want to include a Drools rule file yet but do want to use a business rule task in the process definition?

Best regards,

njames
Champ in-the-making
Champ in-the-making
That is correct. That way I can deploy my processes and business rules independently.
I can allow for having business rules that automate the approval process without mandating it. Making the business rule optional, if you will.
I'm just looking to start a discussion on this, and learn the advantages of Activiti throwing an exception if there are no rules.

Thanks,

Nick.

trademak
Star Contributor
Star Contributor
Hi Nick,

Okay, the advantage of the current approach is that the versioning of the process definition is coupled to the rules that are deployed together.
If the rules would be deployed separately you would also have to point from the business rule task to a specific version / or the latest version of a set of rules.
This introduces quite some complexity.
If you would like to have a separate rules deployment it would make more sense to me to install Drools separately (maybe together with Guvnor) and connect remotely to it from a business rule task / service task. This remote functionality is not yet available in the business rule task but that should be easy to add.

Best regards,

njames
Champ in-the-making
Champ in-the-making
Thanks for the ideas Tijs, I really appreciate it. The versioning would be done by using the latest version that is active (my business rules all have start and end dates). Hence the rule set could be updated on the fly by adding a new, active rule to the rule store.

I did think about using Guvnor to manage the rules, but it seemed easier to merely extend the existing deployment mechanism to find rules in other places.

I'm not sure that I want to use a "remote" drools engine because Activiti is the only process that would be using it. I would be paying the network latency price for no gain.

If I wanted to customize the stock implementation of BusinessRulesTaskActivityBehavior to get some of the rules from an alternate location, what would be the best way to do this? (Sorry for the newbie question).
I have experimented with the custom rules deployer, but it doesn't have direct access to the execution (I want to use one/some of the process variables to guide the rules discovery).

Thanks,

Nick.

frederikherema1
Star Contributor
Star Contributor
If you want to use the execution for determining what rules to use, it's indeed best to extend BusinessRulesTaskActivityBehavior or even start from a clean "org.activiti.engine.impl.bpmn.behavior.TaskActivityBehavior" and lookup the rules from within the execute-method and apply them.

jasonwhite01
Champ in-the-making
Champ in-the-making
Tijs - would you recommend the same remote-rules approach as a valid pattern when limited to not using business rules tasks by Alfresco?

I simply cannot believe there isn't a standard way to use a rules engine via Activiti when deploying process definitions within Alfresco but, seems terribly limited in alfresco….

Any help with either reference patterns and/or examples would help a ton.

trademak
Star Contributor
Star Contributor
So, are you using Drools or something else as your rules engine?
The business rule task currently supports an embedded Drools engine.
But if there's need for remote Drools connectivity that wouldn't be too hard to add.

Best regards,
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.