<div dir="ltr">Maybe I'm wrong and I cannot use this configuration because in some case fail<br><div class="gmail_extra"><br><br><div class="gmail_quote">2014-06-17 13:57 GMT+02:00 Sergio Besada <span dir="ltr"><<a href="mailto:scerquido@gmail.com" target="_blank">scerquido@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Hi,<br><br>I have seen that in the drools version 6.1.0.Beta4, the command fire-until-halt is developed using persistence but drools doesn't let me test it because this command implement the interface "UnpersistableCommand" so I have eliminated this interface and I have tested this configuration. <br>
<br>Surprisingly, Drools works as I expected and doesn't throw any exception, ¿Where is the problem in this configuration?<br><br></div>Here my camel context<br><div><br><?xml version="1.0" encoding="UTF-8"?><br>
<beans xmlns="<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>"<br> xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>"<br>
xmlns:kie="<a href="http://drools.org/schema/kie-spring" target="_blank">http://drools.org/schema/kie-spring</a>"<br> xsi:schemaLocation="<br> <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <br>
<a href="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" target="_blank">http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</a><br> <a href="http://drools.org/schema/kie-spring" target="_blank">http://drools.org/schema/kie-spring</a> <a href="http://drools.org/schema/kie-spring.xsd" target="_blank">http://drools.org/schema/kie-spring.xsd</a><br>
<a href="http://camel.apache.org/schema/spring" target="_blank">http://camel.apache.org/schema/spring</a> <a href="http://camel.apache.org/schema/spring/camel-spring.xsd" target="_blank">http://camel.apache.org/schema/spring/camel-spring.xsd</a>"><br>
<br> <br> <br> <kie:kmodule id="kModule"><br> <kie:kbase name="rules" packages="rules"><br> <kie:ksession name="ksession1" type="stateful"> <br>
<kie:batch><br> <kie:fire-until-halt/><br> </kie:batch> <br> <kie:configuration><br> <kie:jpa-persistence><br> <kie:transaction-manager ref="txManager"/><br>
<kie:entity-manager-factory ref="myEmf"/><br> </kie:jpa-persistence> <br> </kie:configuration><br> <br> <br> </kie:ksession><br>
</kie:kbase><br> </kie:kmodule><br><br> <kie:environment id="env"><br> <kie:entity-manager-factory ref="myEmf"/><br> <kie:transaction-manager ref="txManager"/><br>
</kie:environment><br><br> <br> <bean class="org.postgresql.ds.PGPoolingDataSource" id="jbpm-ds"><br> <property name="serverName" value="localhost"></property><br>
<property name="databaseName" value="drools"></property><br> <property name="portNumber" value="5432"></property><br> <property name="user" value="DWP"></property><br>
<property name="password" value="DWP"></property><br> </bean><br> <br> <br> <bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><br>
<property name="dataSource" ref="jbpm-ds"/><br> <property name="persistenceUnitName" value="org.jbpm.persistence.jpa.local"/><br> </bean><br><br>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"><br> <property name="entityManagerFactory" ref="myEmf"/><br> </bean><br>
<br> <bean id="kiePostProcessor" class="org.drools.osgi.spring.OsgiKModuleBeanFactoryPostProcessor"/><br><br> <bean id="fireALlRulesCommand" class="com.execute.command.FireAllRules"/><br>
<br> <bean id="fireUntilHaltCommand" class="com.execute.command.FireUntilHalt"/><br> <br> <bean id="factStudent" class="com.test.facts.Student"/><br> <br>
<camelContext xmlns="<a href="http://camel.apache.org/schema/spring" target="_blank">http://camel.apache.org/schema/spring</a>"><br>
<route trace="false" id="testRoute"><br> <from uri="timer:testRoute?period=10s"/><br> <to uri="log:message"/><br> <bean method="initStudent" ref="factStudent"/> <br>
<to uri="kie:ksession1?action=insertBody" id="AgeVerification"/><br> <!-- <br> <bean method="fireUntilHalt" ref="fireUntilHaltCommand"/> <br>
<br> <to uri="kie:ksession1?action=execute"/><br> --><br> </route><br> </camelContext> <br> <br></beans><br><br><br></div><div>PD: I have attached my example , it's a maven project<br>
</div><div class="gmail_extra"><br><br><br><br><div class="gmail_quote">2014-06-04 19:04 GMT+02:00 Sergio Besada <span dir="ltr"><<a href="mailto:scerquido@gmail.com" target="_blank">scerquido@gmail.com</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Thank you in advance.</div><div class="gmail_extra"><br><br><div class="gmail_quote">
<div>2014-06-04 18:29 GMT+02:00 Charles Moulliard <span dir="ltr"><<a href="mailto:ch007m@gmail.com" target="_blank">ch007m@gmail.com</a>></span>:<br>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I will have a look to your use case as it is not yet covered and will perhaps require that we modify the kie-camel component</div>
<div><div>
<div class="gmail_extra"><br><br><div class="gmail_quote"><div><div>On Wed, Jun 4, 2014 at 6:02 PM, s b <span dir="ltr"><<a href="mailto:scerquido@gmail.com" target="_blank">scerquido@gmail.com</a>></span> wrote:<br>
</div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div><div dir="ltr"><div><div><div><div><div><div><div><div>I'm testing the drools new version (6.1.0.Beta4) but I have a problem with the Stateful Drools Session.<br>
<br></div>I have deployed in JBoss Fuse ESB the last versión of the drools (drools camel, jbpm, spring, etc), I have atached my camel context bundle (It's a maven project). <br>
<br></div>This is my camel-context<br><br><?xml version="1.0" encoding="UTF-8"?><br><beans xmlns="<a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a>"<br>
xmlns:xsi="<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>"<br> xmlns:kie="<a href="http://drools.org/schema/kie-spring" target="_blank">http://drools.org/schema/kie-spring</a>"<br>
xsi:schemaLocation="<br> <a href="http://www.springframework.org/schema/beans" target="_blank">http://www.springframework.org/schema/beans</a> <br> <a href="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" target="_blank">http://www.springframework.org/schema/beans/spring-beans-3.0.xsd</a><br>
<a href="http://drools.org/schema/kie-spring" target="_blank">http://drools.org/schema/kie-spring</a> <a href="http://drools.org/schema/kie-spring.xsd" target="_blank">http://drools.org/schema/kie-spring.xsd</a><br>
<a href="http://camel.apache.org/schema/spring" target="_blank">http://camel.apache.org/schema/spring</a> <a href="http://camel.apache.org/schema/spring/camel-spring.xsd" target="_blank">http://camel.apache.org/schema/spring/camel-spring.xsd</a>"><br>
<br> <br> <br> <kie:kmodule id="kModule"><br> <kie:kbase name="rules" packages="rules"><br> <kie:ksession name="ksession1" type="stateful"> <br>
<!--<kie:batch><br> <kie:fire-all-rules/><br> </kie:batch> --> <br> <kie:configuration><br> <kie:jpa-persistence><br>
<kie:transaction-manager ref="txManager"/><br> <kie:entity-manager-factory ref="myEmf"/><br> </kie:jpa-persistence> <br>
</kie:configuration><br> <br> <br> </kie:ksession><br> </kie:kbase><br> </kie:kmodule><br><br> <kie:environment id="env"><br>
<kie:entity-manager-factory ref="myEmf"/><br> <kie:transaction-manager ref="txManager"/><br> </kie:environment><br><br> <br> <bean class="org.postgresql.ds.PGPoolingDataSource" id="jbpm-ds"><br>
<property name="serverName" value="localhost"></property><br> <property name="databaseName" value="drools"></property><br> <property name="portNumber" value="5432"></property><br>
<property name="user" value="DWP"></property><br> <property name="password" value="DWP"></property><br> </bean><br> <br> <br> <bean id="myEmf" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"><br>
<property name="dataSource" ref="jbpm-ds"/><br> <property name="persistenceUnitName" value="org.jbpm.persistence.jpa.local"/><br> </bean><br><br>
<bean id="txManager" class="org.springframework.orm.jpa.JpaTransactionManager"><br> <property name="entityManagerFactory" ref="myEmf"/><br> </bean><br>
<br> <bean id="kiePostProcessor" class="org.drools.osgi.spring.OsgiKModuleBeanFactoryPostProcessor"/><br><br> <bean id="fireALlRulesCommand" class="com.execute.command.FireAllRules"/><br>
<br> <camelContext xmlns="<a href="http://camel.apache.org/schema/spring" target="_blank">http://camel.apache.org/schema/spring</a>"><br> <route trace="false" id="testRoute"><br>
<from uri="timer:testRoute?period=10s"/><br>
<to uri="log:message"/><br> <to uri="kie:ksession1?action=insertBody" id="AgeVerification"/><br> <br> <bean method="fireAllRules" ref="fireALlRulesCommand"/> <br>
<to uri="kie:ksession1?action=execute"/><br> <br> </route><br> </camelContext> <br> <br></beans><br><br></div>As you can see it is an scenario where Drools is in an stateful session with persistence configured. <br>
<br>The bundle is executed without errors but I want that Drools executes my rules each time that the route is executed ( fireUntilHalt mode but I wasn't able as seems that this command is not availble in a persisted environment ), for this reason I've created a bean with the command: fireAllRules and I use <to uri="kie:ksession1?action=execute"/> to execute the rules but the problem is that the rules are only executed the first time, only the first time and never in subsequents executions of the route.<br>
<br> The persistece seems to work well ( I can see the datamodel created and populated as expeted in the DB ). <br><br>However if I change to use stateless mode ( no persistence then ), the rules are executed each time that route is executed ( as expected ), and therefore I don´t need the command fireAllRules<br>
<bean method="fireAllRules" ref="fireALlRulesCommand"/> <br> <to uri="kie:ksession1?action=execute"/><br><br><br><br></div>Questions:<br><br></div>Is it possible to have a stateful fireUntilHalt drools session that keeps using the same knowledge session in subsequent camel route executions?<br>
<br></div>If it is not possible, Can I have a stateful ( persisted )drools session and invoke "fireAllRules" whenever I make changes in the knowledge session ( new Facts are inserted )?<br><br></div>I've deep dived into the web looking for examples or documentation of this scenario both in Spring and Blueprint. Does anyone of you have any pointers to documentation on the matter?<br>
<br></div>Kind Regards,<br></div>
<br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><span><font color="#888888"><br></font></span></blockquote></div><span><font color="#888888"><br>
<br clear="all"><span class="HOEnZb"><font color="#888888"><div><br></div>-- <br><div dir="ltr"><div>
Charles Moulliard</div><div>Apache Committer / Architect @RedHat</div><div>Twitter : @cmoulliard | Blog : <a href="http://cmoulliard.github.io" target="_blank"> http://cmoulliard.github.io</a></div><div><br></div></div>
</font></span></font></span></div><span class="HOEnZb"><font color="#888888">
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br></font></span></div></div></blockquote></div><span class="HOEnZb"><font color="#888888"><br>
</font></span></div>
</blockquote></div><br></div></div>
</blockquote></div><br></div></div>