4 Replies Latest reply on Oct 19, 2012 10:03 AM by salaboy21

    Philosophy of rules in jBPM

    fr13d

      Hi all,

       

      I'm new to Drools and we are investigating its potential for a new project (using version 5.4.0). I understand that rules (Expert) and processes (jBPM) have a different approach. As I understand it, rules (potentially a large set) are very effectively applied to facts (potentially also a large set of objects). A process on the other hand operates on process variables and represents (in effect) changes in state - typically one object at a time for the simple reason that you don't want to mix up unrelated facts/variables in the same instance of a process.

       

      As also noted in the Drools documentation, a business might want a mix-and-match approach, using both rules and processes. A typical example (simplified real-world) just to illustrate the previous sentence:

      1. All mobile phone customers with contracts 11 months or older, and who have not received an upgraded in the past 11 months, are eligible to upgrade their phones (RULE)
      2. Eligible customers need to go through the following PROCESS to receive the upgrade:
        1. Check customer's contact details, update if necessary (Task involving web forms)
        2. Do credit check on customer (RULES to determine credit rating)
        3. If sufficiently high credit rating (XOR Gateway):
          • Have customer select preferred phone handset, and supply (Human task)
          • Update inventory (Task)

       

      Ideally, business users/analysts (no Java knowledge) should be able to define most or all of each process and rule, using Guvnor (its graphical editor).

       

      So far, we've worked through various Hello World examples, and have created a simple process (all in Guvnor) that also activates a Rule Task (by using the ruleflow-group attribute in the task as well as in the rule). So far so good. Now we start to add some logic: the rule task modifies the object that triggered it by setting some "outcome" field. The idea is to use this "outcome" value in a gateway (similar to the credit check in the example). However, moving values from facts (rules) to variables (process) involves some complicated Java code (from the business user's POV) that one ideally doesn't want them to do or see. There doesn't seem to be an easy way to reference the same object(s) used in a rule, in process nodes (as they work differently).

       

      1. Are we on the right track in trying to combine rules and processes in this way?
      2. If so, what is the right way (or at least the simplest way) to achieve this?
      3. What is the possibility of a domain object (fact) being used in a long-running process, also being modified by another completely independent rule/process, and one ending up with 2 clashing versions of the object?

       

      Thanks in advance for any views/explanations about the fundamental workings of rules and jBPM in Drools, and also for any practical examples to make the above work.

        • 1. Re: Philosophy of rules in jBPM
          salaboy21

          Hi,

          Did you check out my blog posts about this topic?

          I've written 3 articles about this: http://salaboy.com/2012/07/29/processes-rules-or-rules-processes-3x/

          That one contains links to the others.

           

          I will be publushing at least 3 more posts in the next months related with those topics.

          I would like to get your feedback to write more specific stuff.

           

          I usually recommend (and this is my personal opinion only) to try to describe and test what do you want to achieve using Unit Tests. Once you define what is your domain and what is the level of your users you can create a custom tool for them if Guvnor doesn't give you what you are looking for. I've seen in the past tools related with the healtcare industry being built on top of drools for very specific users which doesn't want to even know about the rules that are being created on the back.

           

          Cheers

          • 2. Re: Philosophy of rules in jBPM
            fr13d

            Hello Mauricio

            Your posts are VERY helpful in explaining these things - we guessed some of it, but couldn't find much about it in documentation. Thanks for pointing me in the right direction, unfortunately couple of days' googling and reading hasn't shown me your blog yet :-( I willl certainly look out for future posts, and as I gain more experience I might be able to make more useful suggestions/ask better questions ;-)

            We think that Guvnor's tools are just about right for the level of our business analysts (give or take), and we found the Test Scenarios in it would probably be useful for them to test them standalone.

            I guess it would be fairly easy to generate .DRL/.BPMN2 files by just having some program output text files - or is there another way?

            I agree, test-driven development is the way to go once we start development.

            Ciao

            • 3. Re: Philosophy of rules in jBPM
              salaboy21

              As you may know, guvnor is a set of components that can be used separately, so for example if you want to model business process you can pick the process designer embeded it in your application and then find a way to generate the rules based on a metaphor that suits your business analysts needs. You will find that this is a very incremental approach when you need to decide how much control you will give the analysts during the first phases of your adoption. Usually you will see that during the initial period of adoption your analysts can only see the rules that are being executed, then you can provide a way to parameterize them and finaly you can give them an authoring tool.

               

              Hope this helps.

               

              Cheers

              • 4. Re: Philosophy of rules in jBPM
                salaboy21

                If you can please, mark this question as Answered, more users can benefit from it