10 Replies Latest reply on Apr 21, 2010 1:44 PM by Felix Jose

    How to use rules in JBPM-4.3

    Felix Jose Newbie

      Hi All,

       

      I am having some doubts on using rules in JBPM-4.3.:

       

      1. How can we use the rules in JBPM-4.3?

      2. Do we need to use Drools for the same or we have to use the <rules> node in JBPM?

      3. if need to use Drools how can we integrate Drools and JBPM?

       

      And I am having another general doubt in JBPM-4.3:

       

      I am having a main process and two subprocess. In that the main process should execute concurrently with one of its subprocess and once that subprocess get completed the control should come back to the main process and the second subprocess should start parallely with the main process.

      The main process should not get end untill and unless the two subprocesses got completed. The main criteria is, the main process should be execute parallely with the two subprocess.

       

      As I get from JBPM documentations the main process will be in wait state when the subprocess is in execution. Is there any way that I can do my above requirement with JBPM-4.3.

       

      Please send a response to this as soon as possible as I have to complete my project poc by 23rd April 2010. I will be grateful to you if you give me an answer to my queries.

       

      Thank You Very Much,

       

      With Regards,

      Felix K Jose

        • 1. Re: How to use rules in JBPM-4.3
          HuiSheng Xu Master

          Hi Felix,

            The jBPM-4.3 already support drools integartion. You could use RulesActivity directly.

           

            If you want to let all the child executions of a forkActivity running parallel, you could set continue attribute like below:

           

          <fork>

            <transition name="A" to="A"/>

            <transition name="B" to="B"/>

          </fork>

           

            <java name="A" continue="async"/>

           

            <java name="B" continue="async"/>

          • 2. Re: How to use rules in JBPM-4.3
            Felix Jose Newbie

            Hi Huisheng,

            Thank you for your reply. But as I am new to JBPM, can you please give an example of using drools from JBPM.

             

            Regarding my requirement, the main process should start the subprocess and the main process should continue execution. I am not talking about parallely executing two subprocess.

            And also the main criteria is, the main process should continue processing one main task untill and unless the two subprocess done the other two tasks.

            Can you please let me know about this.

             

            Thank You very much,

            Felix K Jose

            • 3. Re: How to use rules in JBPM-4.3
              HuiSheng Xu Master

              Hi Felix,

                Of course, I can give you a sample with RulesActivity. I put the jpdl.xml and dsl files in attach. You can have a try.

               

                By the way, I can't make sure what you want to do in process. You say the main process will start a sub process, but there is not a parallel gateway. Then the main process could still keep running and do some task(I don't known what task should be set here for you, human Task or Service Task?) At the end, the main process could using some technology to notice that both of sub process have been done( I can only see one sub process be created in above? Where is the other sub process comes from?).  Because there is so many unclearly issues, I can't make a process for you, maybe you could show me more details.

               

                And it is too late, I have to go to bed, see you next day.

               

              cheers.

               

              Xu Hui Sheng

              • 4. Re: How to use rules in JBPM-4.3
                Maciej Swiderski Master

                Hi,

                 

                in addition to example given by Huisheng Xu you can find some interesting information about rules and rules decision activity in dev guide:

                http://docs.jboss.com/jbpm/v4/devguide/html_single/#rulesdecision

                 

                I am nit sure I got your point but in my opinion you could do it with fork and join. Meaning that to execute a subprocess and main process in pararell you use fork where one branch is the subprocess and the other is main path. After you join them and do it quite the same for second subprocess. That way execution will wait in join until both branches are finished.

                 

                HTH

                Maciej

                • 5. Re: How to use rules in JBPM-4.3
                  Felix Jose Newbie

                  Hi,

                  Thank You very much Huisheng for the reply and for the attached drool sample.

                   

                  And more about my requirement is as follows:

                   

                  I am having a Research web page (html) in that there are 3 entities. The first entity is the primary entity and the other two entities are secondary entities.

                   

                  In JBPM I am starting a process (i.e., the main process) that opens up the web page for researching the entities present in that.  As the web page is having three entities. The research on the primary entity should execute with the main process and the research on the other two entities should execute with two sub process.

                   

                  I have tried to execute them by using fork.

                   

                  <fork name="researchFork" g="711,140,48,48">

                        <transition name="to primary entity research" to="primaryEntityResearch" g="660,164:-31,-18"/>----Main process node is primaryEntityResearch

                        <transition name="to first secondary entity research" to="firstSecondaryEntityResearch" g="860,164:-97,-23"/>----Subprocess1 is firstSecondaryEntityResearch

                        <transition name="to second secondary entity research" to="secondSecondaryEntityResearch" g="860,164:-97,-23"/>-----Subprocess2 is firstSecondaryEntityResearch

                     </fork>

                  I have attached the process definition snippet with this.

                   

                  But if we use fork then the completed processes will wait in the join of it for the other process to complete. But my aim is as soon as the two subprocesses get completed those should come to the primary entity research node (the main process node in the fork) and then only the main process node i.e., the primary entity research node should end.

                   

                  Also can you please give me a solution how can we use fork without join so that the completed tasks don’t need to wait in the join to complete the other forked jobs(processes).

                   

                  Also can you please give me some example of different usage of task node?

                  • 6. Re: How to use rules in JBPM-4.3
                    Felix Jose Newbie

                    Hi Maciej,

                    Thank you very much for the reply you have given and also please find the requiremnt I have given in the other reply. And please give me an answer for the same.

                     

                    Thank You,

                    Regards,

                    Felix Jose

                    • 7. Re: How to use rules in JBPM-4.3
                      HuiSheng Xu Master

                      Hi  Felix,

                        You want to let some branches of process executed parallel, when two sub processes has completed, they will tell the main process the results. Am I right?

                        So if main process are quicker than two sub processes, will the whole process ended or the main process will wait for two sub process completing then end the whole process?

                       

                        If the main process must wait for two sub processes, you could use fork and join to implement this, otherwise, we have find another way to do this.

                      • 8. Re: How to use rules in JBPM-4.3
                        Felix Jose Newbie

                        Hi Huisheng,

                         

                        Yes, when two sub processes has completed, they should tell the main process the results. The main process will not quicker than the two sub processes.

                        So can you please give me some solution on the same?

                         

                        Thank You Very much,

                        With Regards,

                        Felix K Jose

                        • 9. Re: How to use rules in JBPM-4.3
                          HuiSheng Xu Master

                          Hi Felix,

                            Because of the complexity for implementing sending messages between difference executions, I suggest you using simple fork/join to implement your requirement.

                           

                            If you don't want to use fork/join, then you can consider this solution.

                           

                            Create a thread and store main process id and its sub process ids, then let the thread checks when sub process ends. Once the thread finds a sub processed had ended, it could send a message to main process.  The problem is you must control thread's lifecycle all be yourself, and have to prepare to handle the exception occured on process executing.  It is mostly like a real time monitor management system.  If you really want to do this, please make a good plan first.

                          1 of 1 people found this helpful
                          • 10. Re: How to use rules in JBPM-4.3
                            Felix Jose Newbie

                            Hi,

                             

                            Thank you Huisheng for your reply. I will try your solution but it is a little difficult. And please let me know if anybody get anyother solution on this. PLease anybody please help as I am struggling  with this for a long time.....

                             

                            Thank You very much,

                            With Regards,

                            Felix K Jose