[rules-users] Fuse ESB & Drools 6 problem

s b scerquido at gmail.com
Wed Jun 4 12:02:52 EDT 2014


I'm testing the drools new version (6.1.0.Beta4) but I have a problem with
the Stateful Drools Session.

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).

This is my camel-context

<?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:kie="http://drools.org/schema/kie-spring"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
       http://drools.org/schema/kie-spring
http://drools.org/schema/kie-spring.xsd
       http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">



 <kie:kmodule id="kModule">
        <kie:kbase name="rules" packages="rules">
            <kie:ksession name="ksession1" type="stateful">
            <!--<kie:batch>
               <kie:fire-all-rules/>
               </kie:batch> -->
            <kie:configuration>
                <kie:jpa-persistence>
                    <kie:transaction-manager ref="txManager"/>
                    <kie:entity-manager-factory ref="myEmf"/>
                </kie:jpa-persistence>
            </kie:configuration>


            </kie:ksession>
        </kie:kbase>
    </kie:kmodule>

    <kie:environment id="env">
       <kie:entity-manager-factory ref="myEmf"/>
        <kie:transaction-manager ref="txManager"/>
    </kie:environment>


  <bean class="org.postgresql.ds.PGPoolingDataSource" id="jbpm-ds">
   <property name="serverName" value="localhost"></property>
   <property name="databaseName" value="drools"></property>
   <property name="portNumber" value="5432"></property>
   <property name="user" value="DWP"></property>
   <property name="password" value="DWP"></property>
  </bean>


    <bean id="myEmf"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="dataSource" ref="jbpm-ds"/>
        <property name="persistenceUnitName"
value="org.jbpm.persistence.jpa.local"/>
    </bean>

    <bean id="txManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="myEmf"/>
    </bean>

    <bean id="kiePostProcessor"
class="org.drools.osgi.spring.OsgiKModuleBeanFactoryPostProcessor"/>

    <bean id="fireALlRulesCommand"
class="com.execute.command.FireAllRules"/>

  <camelContext xmlns="http://camel.apache.org/schema/spring">
    <route trace="false" id="testRoute">
        <from uri="timer:testRoute?period=10s"/>
         <to uri="log:message"/>
         <to uri="kie:ksession1?action=insertBody" id="AgeVerification"/>

         <bean method="fireAllRules" ref="fireALlRulesCommand"/>
         <to uri="kie:ksession1?action=execute"/>

    </route>
  </camelContext>

</beans>

As you can see it is an scenario where Drools is in an stateful session
with persistence configured.

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.

 The persistece seems to  work well ( I can see the datamodel created and
populated as expeted in the DB ).

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
<bean method="fireAllRules" ref="fireALlRulesCommand"/>
 <to uri="kie:ksession1?action=execute"/>



Questions:

Is it possible to have a stateful fireUntilHalt drools session that keeps
using the same knowledge session in subsequent camel route executions?

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 )?

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?

Kind Regards,
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/rules-users/attachments/20140604/42c2fd5c/attachment-0001.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: com.test.drools.spring.rar
Type: application/rar
Size: 9141 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/rules-users/attachments/20140604/42c2fd5c/attachment-0001.bin 


More information about the rules-users mailing list