Uploaded image for project: 'JBRULES'
  1. JBRULES
  2. JBRULES-3722

Ruleflow only executes all ruleflow-groups one time in Stateless session after drools-server restart

This issue belongs to an archived project. You can view it, but you can't modify it. Learn more

    XMLWordPrintable

Details

    • Hide
      • Create simple rule project with rules and a ruleflow.
      • Compile and deploy the rules to drools-server.
      • Execute the rule engine by sending a JSON command to drools-server via cURL
        • the first execution should work correctly. All ruleflow-group nodes should fire
        • the second execution with the same data should fail. Only the first ruleflow-group node should fire.
      • Restart drools-server by going to JBoss console and disable / re-enable the service.
      • Execute the rules again and they should work correctly. Then execute again and they should fail.

      Detailed steps to recreate:

      Create a simple 3 step ruleflow.

      START --> Step1 --> Step2 --> Step3 --> END

      I have created a sample rule project for testing this issue. This was created in Guvnor 5.5. The text below is from the view
      source code window in Guvnor:

      package SimpleRuleflowTest
      
      declare Input
          Name: String
      end
      
      declare Output
          Name: String
      end
      
      declare InternalData
          StepNumber: Integer
      end
      
      rule "Step_1"
          ruleflow-group "Step1"
          dialect "mvel"
          when
              Input( )
          then
              InternalData fact0 = new InternalData();
              fact0.setStepNumber( 1 );
              insert( fact0 );
      end
      
      rule "Step_2"
          ruleflow-group "Step2"
          dialect "mvel"
          when
              InternalData( StepNumber == 1 )
          then
              InternalData fact0 = new InternalData();
              fact0.setStepNumber( 2 );
              insert( fact0 );
      end
      
      rule "Step_3"
          ruleflow-group "Step3"
          dialect "mvel"
          when
              InternalData( StepNumber == 2 )
          then
              Output fact0 = new Output();
              fact0.setName( "Finished with Step 3" );
              insert( fact0 );
      end
      

      I am sending the following commands to the server using JSON:

      {
      	batch-execution: {
      	    lookup:"ksession1",
      		commands: [{	
      			insert: {
      				object: {
      					"SimpleRuleflowTest.Input": {
      						"Name": "Test"
      					}
      				},
      				returnObject:"false",
      			}
      		},		
      		{
      			start-process: {
      				process-id: "TestRuleflow",
      
      			}
      		},
      		{
      			fire-all-rules: {
      				max:"10",
      				out-identifier: "firedActivations"
      			}
      		},		
      		{
      			get-objects: {
      				out-identifier: "objects"
      			}
      		}]
      	}
      }
      

      For my tests I am using cURL to send the commands to the drools-server. Below the cURL command line I am using to test:

      curl  -v -H "Content-Type: text/plain" --data
      "{\"batch-execution\":{\"lookup\":\"ksession1\",\"commands\":[{\"insert\":{\"object\":{\"SimpleRuleflowTest.Input\":{\"Name\":\"Test\"}}}},{\"start-process\":{\"process-id\":\"TestRuleflow\"}},{\"fire-all-rules\":{\"out-identifier\":\"firedActivations\"}},{\"get-objects\":{\"out-identifier\":\"objects\"}}]}}"
      http://localhost:8080/drools-server/kservice/rest/execute*
      

      Below is the JSON returned after the first execution just after the drools
      server is started. Notice that 3 rules are executed and an Output object is
      created and returned:

      {
          "execution-results": {
              "results": {
                  "result": [{
                      "identifier": "firedActivations",
                      "value": {
                          "int": 3
                     }
                  },
                  {
                      "identifier": "objects",
                      "value": {
                          "list": {
                              "SimpleRuleflowTest.InternalData": [{
                                  "StepNumber": 1
                              },
                              {
                                  "StepNumber": 2
                              }],
                              "SimpleRuleflowTest.Input": {
                                  "Name": "Test"
                              },
                              "SimpleRuleflowTest.Output": {
                                  "Name": "Finished with Step 3"
                              }
                          }
                      }
                  }]
              }
          }
      }
      

      Below is the JSON returned for every other call to the drools server after
      the first time. Notice that only one rule is executed and no Output object
      is created:

      {
          "execution-results": {
              "results": {
                  "result": [{
                      "identifier": "firedActivations",
                      "value": {
                          "int": 1
                      }
                  },
                  {
                      "identifier": "objects",
                      "value": {
                          "list": {
                              "SimpleRuleflowTest.Input": {
                                  "Name": "Test"
                              },
                              "SimpleRuleflowTest.InternalData": {
                                  "StepNumber": 1
                              }
                          }
                      }
                  }]
              }
          }
      }
      
      Show
      Create simple rule project with rules and a ruleflow. Compile and deploy the rules to drools-server. Execute the rule engine by sending a JSON command to drools-server via cURL the first execution should work correctly. All ruleflow-group nodes should fire the second execution with the same data should fail. Only the first ruleflow-group node should fire. Restart drools-server by going to JBoss console and disable / re-enable the service. Execute the rules again and they should work correctly. Then execute again and they should fail. Detailed steps to recreate: Create a simple 3 step ruleflow. START --> Step1 --> Step2 --> Step3 --> END I have created a sample rule project for testing this issue. This was created in Guvnor 5.5. The text below is from the view source code window in Guvnor: package SimpleRuleflowTest declare Input Name: String end declare Output Name: String end declare InternalData StepNumber: Integer end rule "Step_1" ruleflow-group "Step1" dialect "mvel" when Input( ) then InternalData fact0 = new InternalData(); fact0.setStepNumber( 1 ); insert( fact0 ); end rule "Step_2" ruleflow-group "Step2" dialect "mvel" when InternalData( StepNumber == 1 ) then InternalData fact0 = new InternalData(); fact0.setStepNumber( 2 ); insert( fact0 ); end rule "Step_3" ruleflow-group "Step3" dialect "mvel" when InternalData( StepNumber == 2 ) then Output fact0 = new Output(); fact0.setName( "Finished with Step 3" ); insert( fact0 ); end I am sending the following commands to the server using JSON: { batch-execution: { lookup: "ksession1" , commands: [{ insert: { object: { "SimpleRuleflowTest.Input" : { "Name" : "Test" } }, returnObject: " false " , } }, { start-process: { process-id: "TestRuleflow" , } }, { fire-all-rules: { max: "10" , out-identifier: "firedActivations" } }, { get-objects: { out-identifier: "objects" } }] } } For my tests I am using cURL to send the commands to the drools-server. Below the cURL command line I am using to test: curl -v -H "Content-Type: text/plain" --data "{\" batch-execution\ ":{\" lookup\ ":\" ksession1\ ",\" commands\ ":[{\" insert\ ":{\" object\ ":{\" SimpleRuleflowTest.Input\ ":{\" Name\ ":\" Test\ "}}}},{\" start-process\ ":{\" process-id\ ":\" TestRuleflow\ "}},{\" fire-all-rules\ ":{\" out-identifier\ ":\" firedActivations\ "}},{\" get-objects\ ":{\" out-identifier\ ":\" objects\ "}}]}}" http: //localhost:8080/drools-server/kservice/ rest /execute* Below is the JSON returned after the first execution just after the drools server is started. Notice that 3 rules are executed and an Output object is created and returned: { "execution-results" : { "results" : { "result" : [{ "identifier" : "firedActivations" , "value" : { " int " : 3 } }, { "identifier" : "objects" , "value" : { "list" : { "SimpleRuleflowTest.InternalData" : [{ "StepNumber" : 1 }, { "StepNumber" : 2 }], "SimpleRuleflowTest.Input" : { "Name" : "Test" }, "SimpleRuleflowTest.Output" : { "Name" : "Finished with Step 3" } } } }] } } } Below is the JSON returned for every other call to the drools server after the first time. Notice that only one rule is executed and no Output object is created: { "execution-results" : { "results" : { "result" : [{ "identifier" : "firedActivations" , "value" : { " int " : 1 } }, { "identifier" : "objects" , "value" : { "list" : { "SimpleRuleflowTest.Input" : { "Name" : "Test" }, "SimpleRuleflowTest.InternalData" : { "StepNumber" : 1 } } } }] } } }

    Description

      Given a simple ruleflow:
      START --> Step1 --> Step2 --> Step3 --> END

      When the drools-server has just been started the rules and ruleflow-groups execute correctly. All ruleflow-groups (Step1, Step2, and Step3) are hit.

      The second rule execution request does not work correctly. Only ruleflow-group Step1 is hit. From that point on ruleflow-groups Step2 and Step3 are not hit until the drools-server is restarted.

      I am using the following batch-execution commands in this order: insert, start-process, fire-all-rules, get-objects.

      If I use the exact same commands in the same order from a Java project instead of using drools-server then it works correctly every time. All ruleflow-group nodes are executed properly every time for a stateless session.

      Attachments

        Activity

          People

            mproctor@redhat.com Mark Proctor
            tslonaker_jira Tim Slonaker (Inactive)
            Archiver:
            rhn-support-ceverson Clark Everson

            Dates

              Created:
              Updated:
              Archived:

              PagerDuty