10 Replies Latest reply on Mar 10, 2010 3:20 AM by swiderski.maciej

    jBPM 4.3 and business rules/Drools integration

    patriciab

      Hi all,

       

      I implemented a couple of use cases for checking the integration of Drools rule within a jBPM workflow definition. It is a great step forward in having business rules integrated with jBPM activies, and allow the end user to specify the business rules to be invoked, but I ran into a few limitations, and I have a few questions about that.


      1) jBPM expects to find the business rule deployed on the same deployment package with the process definition that is using that rule. IMHO this creates a pretty hard dependency between the rule files and the process definitions files, dependency that does not feel natural, as the process definitions changes and rule changes are not following the same pattern. On the real use case I can see business rules changing more frequent than the process definitions, and I also can see the same business rule being used by more than one process definition. And the process definitions that use the same business rule can be deployed on different deployment packages, on real life.

      But having the constraint that the business rule and process definition that is using it to be on the same deployment package, pretty much imposes that all process definitions and all business rules for an application be deployed on the same deployment package, and every time when a process definition is modified to redeploy the whole package, not just the updated process definition.

       

      I wonder if in the future releases, there is any alternative to this hard dependency between the business rule files and the process definition files being on the same deployment package. I wonder if it would make more sense to allow injection of the KnowledgeRule service into the jBPM RuleDeployer, and that service will know to return the correct KnowledgeBase based on the rule package and/or rule name, and/or rule file. This KnowledgeRule service will take care of loading the business rules from a custom location, and not from the jBPM deployment.


      2) jBPM expects that all rule files are extension ".drl". This seems very limiting as Drools engine also has the decision table rules as excel files, or csv files, and also business rules using the designer with ".brl" file extension.

      Is any plan for future releases to include the other rule files extensions besides the ".drl" one?

       

      3) jBPM rule activity allows to specify the facts for a rule, and all rules deployed with the same process definition are fired.

      I wonder if there is any plan for future releases to allow for a more granular rule state configuration, when a user can specify either the rule name, or the rule package, besides the rule facts. I can see on large applications business rules using the same facts, but actually having different functionality, and being able to specify the rule name or package, will fire the expected rule only.

       

      I wonder if anybody else tried the jBPM Drools integration and whether it found out the same limitations as me. Any feedback is useful.

       

      Thanks.

        • 1. Re: jBPM 4.3 and business rules/Drools integration
          kukeltje

          1) Yes, it is a hard dependency, but it is also a tradeoff between a simple way of managing a set of resources vs a full blown governance system with version management, deployment management etc. So unless the latter becomes available, I think the current way is what is there which I think is sufficient for a lot if not most usecases. Ofcourse, we are always open to contributions, even small ones that take away the some of the limitations without making everything to complex.

           

          2) No idea... there is nothing in jira, and some of the 'choices' were not realy choices in the sense that limitations were put in place deliberately. Again, in many cases it is sufficient for now.

           

          3) Some discussion about this can be found in the developer forum. The developer of the rules integration has the opinion that it currently is sufficient to just fire all rules and have less granularity. This compared to the number 1 and 2 I agree with you.

           

          Thanks for the thorough analysis and feedback.

           

          Cheers,

           

          Ronald

          • 2. Re: jBPM 4.3 and business rules/Drools integration
            patriciab

            Thanks for your answer.

             

            1) I can see the reason for bundling process definition and business rules together. But for the application that I am working on, I need the concept of global business rules, that are used by multiple process flow definitions and process definition versions. These global rules also should be retrieved from repository and allow business users to modify them at runtime. So, the solution that would work, is that the workflow engine takes care of process definition management and versioning, and the business rule engine takes care of the rule files management and versioning. The developer will take care of associating the business rule with the process definition that is using when defining the process definition. It may not be the best approach, and it may left out other use cases, but it makes more sense in my case.

             

            My initial question was more whether there is any plan for the future releases to make this more flexible. I'll be thinking about your advice on contributing, if I make it working .

            • 3. Re: jBPM 4.3 and business rules/Drools integration
              praneet

              hey patricia

                am unable to do integration of same ,i want to know how you have deployed jbpm and rule file together.

                u mad .bar or something else. if bar ,how to make .bar files

               

              thanks in advance

              • 4. Re: jBPM 4.3 and business rules/Drools integration
                kukeltje

                Patricia,

                 

                The developer will take care of associating the business rule with the process definition that is using when defining the process definition.

                 

                Is where I've seen things go wrong, but I understand your usecase. Luckily jBPM is very flexible and you can write some small java code that remotely calls a rules-engine and take the return value to decide which transition to take. Should not be that difficult. You can pass rule file names etc to this class from the processdefinition.

                 

                Cheers,

                 

                Ronald

                • 5. Re: jBPM 4.3 and business rules/Drools integration
                  swiderski.maciej

                  Decision Handler seems to be the right place to put the custom code to deal with rules execution on remote rules engine.

                   

                  Perhaps that could be a "nice to have" feature in JBPM - to ship such a class (implementation of decision handler) that can easily talk to Drools. What is your opinion?

                   

                  /Maciej

                  • 6. Re: jBPM 4.3 and business rules/Drools integration
                    swiderski.maciej

                    Just make sure that rules file is included in that archive (bar).

                     

                    BTW. I think you should start new discussion since that sounds like a new topic.

                     

                    /Maciej

                    • 7. Re: jBPM 4.3 and business rules/Drools integration
                      patriciab

                      Hey,

                       

                      You can use the .bar package where you need to bundle the process definition and business rules files ( .drl).

                      Also, you can use the repositoryService, and create a NewDeployment object; add the process definition and business rules as resources from classpath or as inputstream to the NewDeployment object. After you added all your resources, call deploy method on the NewDeployment object. Hope it helps you.

                      • 8. Re: jBPM 4.3 and business rules/Drools integration
                        kukeltje
                        ESB node first (oops, sounds like I should have used a new topic )
                        • 9. Re: jBPM 4.3 and business rules/Drools integration
                          praneet

                          thanks for replying,

                              actually am gonethru following link for integration by tom bayenes

                           

                          http://processdevelopments.blogspot.com/2010/01/blending-processes-and-rules-with-jbpm.html

                           

                          here he has written

                             . jBPM creates a KnowledgeBase based on all .drl files that are included in a business archive deployment.

                           

                          but am not using .bar file so how will jbpm create knowledgeBase in this condition.

                             whether i have to write that legacy code of knowledgebase manually or it will

                          be automatically created

                          • 10. Re: jBPM 4.3 and business rules/Drools integration
                            swiderski.maciej

                            In my opinion jBPM will create KnowledgeBase based on the resources that are deployed to database regardless of how they were packaged.Resources are kept in db as separate instances (class, xml, drl, etc) not as whole package (bar).

                             

                            So if you deploy your process definition (with all its resources - classes, rules, etc), let's called it manually (using repositoryService) jBPM will create KnowledgeBase based on resources retrieved from data base for the process definition.