[rules-users] Ruleflow not working with stateless session in drools-server 5.5.0.Final

tslonaker tslonaker+drools at gmail.com
Fri Jan 18 14:45:51 EST 2013


I have come up with steps to recreate the problem I am having with the
ruleflow stopping on the first step when using a stateless session. 
Hopefully it is simply something that I don’t have configured correctly. 
Any help would be appreciated.  

My ruleflow looks like this:

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

Below is what the Model and the Rules look like for my test.  I created the
rules using Guvnor’s guided rule editor.  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 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
                        }
                    }
                }
            }]
        }
    }
}*

Here are the details of my setup:
-	Drools server 5.5.0 Final 
-	Drools Guvnor 5.5.0 Final to create the rules
-	Drools server and guvnor are hosted in JBoss 7.1
-	The OS is Windows 7

Knowledge-services.xml:

*<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:drools="http://drools.org/schema/drools-spring"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                           http://drools.org/schema/drools-spring
http://drools.org/schema/drools-spring-1.3.0.xsd">
  <drools:grid-node id="node1"/>
  <drools:kbase id="kbase1" node="node1">
    <drools:resources>
      <drools:resource type="PKG"
source="file:C:/DroolsRulePackages/SimpleRuleflowTest_1.pkg"/>
    </drools:resources>
  </drools:kbase>
  <drools:ksession id="ksession1" type="stateless" kbase="kbase1"
node="node1"/>
</beans>*


Camel-server.xml:

*<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:cxf="http://camel.apache.org/schema/cxf"
       xmlns:jaxrs="http://cxf.apache.org/jaxrs"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
       http://camel.apache.org/schema/cxf
http://camel.apache.org/schema/cxf/camel-cxf.xsd
       http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd
    ">
    
  <import resource="classpath:META-INF/cxf/cxf.xml" />
  <import resource="classpath:META-INF/cxf/cxf-servlet.xml" />
  <cxf:rsServer id="rsServer"  
                address="/rest"
                serviceClass="org.drools.jax.rs.CommandExecutorImpl">
       <cxf:providers>
           <bean class="org.drools.jax.rs.CommandMessageBodyReader"/>
       </cxf:providers>
  </cxf:rsServer>  
  
  <cxf:cxfEndpoint id="soapServer"
            address="/soap"
             serviceName="ns:CommandExecutor"
             endpointName="ns:CommandExecutorPort"
          wsdlURL="soap.wsdl"
          xmlns:ns="http://soap.jax.drools.org/" >
    <cxf:properties>
      <entry key="dataFormat" value="MESSAGE"/>
      <entry key="defaultOperationName" value="execute"/>
    </cxf:properties>
  </cxf:cxfEndpoint>

  <bean id="droolsPolicy" class="org.drools.camel.component.DroolsPolicy" />  
    
  <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">    
    <route>
       <from uri="cxfrs://bean://rsServer"/>
       <policy ref="droolsPolicy">
               <unmarshal ref="json" />       
               <to uri="drools:node1/ksession1" />
               <marshal ref="json" />
       </policy>
    </route>        

    <route>
      <from uri="cxf://bean://soapServer"/>
      <policy ref="droolsPolicy">
        <unmarshal ref="xstream" />       
        <to uri="drools:node1/ksession1" />
        <marshal ref="xstream" />
      </policy>
    </route>
  </camelContext>
</beans>
*



--
View this message in context: http://drools.46999.n3.nabble.com/Ruleflow-not-working-with-stateless-session-in-drools-server-5-5-0-Final-tp4021624p4021652.html
Sent from the Drools: User forum mailing list archive at Nabble.com.



More information about the rules-users mailing list