8 Replies Latest reply on Mar 9, 2011 10:09 AM by jmfaerman

    Help with examples

    jmfaerman

      I am building some example processes, much like salaboy's community training, but with some more basic examples. I am now building a process that receives the hour of day as a parameter and greets "good morning/evening/night"  according to the rules.

       

      Unfortunately, my rule doesn't fire. Can anyone help me find out why?

       

      Process: http://cursos.googlecode.com/svn/trunk/JBPM/Code/src/main/resources/ex03_greetings.bpmn

          Rules: http://cursos.googlecode.com/svn/trunk/JBPM/Code/src/main/resources/ex03_greetings.drl

           Code: http://cursos.googlecode.com/svn/trunk/JBPM/Code/src/main/java/com/googlecode/cursos/jbpm/Ex03_Greetings.java

       

      Project: http://cursos.googlecode.com/svn/trunk/JBPM/Code/ (SVN / MVN)

       

      Thanks in advance,

      Julio

        • 1. Help with examples
          salaboy21

          Hi Julio,

          Great Initiative. Do you think that worth it to copy your examples inside the community training? Would be really nice to have all the community examples together in the same repo. do you think that we can join efforts to make the best community training available?

          Greetings

           

          PS: can you share the logs, to see what's happening .. the source code looks fine at first sight...

          1 of 1 people found this helpful
          • 2. Help with examples
            jmfaerman

            Sure, that would be great!

            Should i fork your Drools_jBPM5-Training-Examples or you add me as a colaborator (github user: jfaerman) ?

             

            I can see in the logs that the WorkflowProcessInstance gets asserted, but the rules don't match...

            • 3. Help with examples
              salaboy21

              Great. I'm just adding you to github.. We use a couple of conventions there for the examples. But we can make the necessary changes to make them uniform.

              Can you copy the logger output here to see whats happening?

               

              Greetings.

               

              I will create new issues so we can coordinate how to include the examples inside that repo.

              • 4. Help with examples
                jmfaerman

                Here it is the logger out:

                 

                BEFORE RULEFLOW VARIABLE CHANGED hourOfDay=8h process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW VARIABLE CHANGED hourOfDay=8h process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW STARTED process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW NODE TRIGGERED node:StartProcess[id=1] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW NODE TRIGGERED node:Hello[id=2] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                ### Starting Greetings process ###

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW NODE TRIGGERED node:Define Period[id=3] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW NODE TRIGGERED node:Define Period[id=3] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW NODE TRIGGERED node:Hello[id=2] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW NODE TRIGGERED node:StartProcess[id=1] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW STARTED process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW NODE TRIGGERED node:Bye[id=4] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                ### Finishing Greetings process ###

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW NODE TRIGGERED node:EndProcess[id=5] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                BEFORE RULEFLOW COMPLETED process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW COMPLETED process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW NODE TRIGGERED node:EndProcess[id=5] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                AFTER RULEFLOW NODE TRIGGERED node:Bye[id=4] process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                null process:Greetings[id=com.googlecode.cursos.jbpm.greetings]

                OBJECT ASSERTED value:WorkflowProcessInstance1 [processId=com.googlecode.cursos.jbpm.greetings,state=2] factId: 1

                • 5. Help with examples
                  salaboy21

                  looks like your process is finishing before you insert the process instance to the working memory. That's why you don't have any activation and zero rules fired.

                  You can try adding in your first script node the insertion of the processInstance to the knowledge session. In that way you will probably get an activation and a firing.

                   

                  Take a look at the documentation that mention that if there are no rules activated inside the rule task the execution will continue.

                  Greetings.

                  • 6. Re: Help with examples
                    jmfaerman

                    Yes, that did it

                     

                    {code:xml}

                        <scriptTask id="_2" name="Hello" >

                          <script>

                              System.out.println("### Starting Greetings process ###");

                              org.drools.runtime.process.WorkflowProcessInstance process = (org.drools.runtime.process.WorkflowProcessInstance)kcontext.getProcessInstance();

                              kcontext.getKnowledgeRuntime().insert(process);

                              System.out.println("### Inserted process instance ###");

                          </script>

                        </scriptTask>

                    {code}

                     

                    But it is stil a bit of a hack... it would be nice to be able to "prepare" the process before starting it or even having the process instance inserted automatically.

                     

                    Thanks a lot Mauricio

                    • 7. Re: Help with examples
                      salaboy21

                      Yes, that's true. We usually do that kind of things in the back. In old Drools Flow we use the input/output actions for that kind of things. but In the BPMN2 spec we don't have that concepts.

                      Having a script task it's a hack, thats true, we never recommend to add technical tasks to your business processes.

                      at least the hack works?

                      Greetings.

                      • 8. Re: Help with examples
                        jmfaerman

                        Yes, it works, moving forward!